?? 例5-1.java
字號:
//例5.1
public class tt
{
public static void main(String args[ ])
{
subThread t1= new subThread(" First");
subThread t2= new subThread(" Second");
t1.start( );
t2.start( );
}
}
class subThread extends Thread
{ public subThread(String str)
{
super(str);
}
//注意:Thread類中的run( )方法具有public屬性,
//覆蓋該方法時,前面必須帶上public。
public void run( )
{
for(int i=0;i<10;i++)
{
System.out.println( i+ " " + getName( ));
try
{ sleep( (int)( Math.random( )*1000 ) ); }
catch(InterruptedException e) { }
}
System.out.println("Finished! " + getName( ));
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -