?? newthread2.java
字號:
class NewThread2 implements Runnable
{
Thread t;
NewThread2()
{
t=new Thread(this,"Demo2 Thread");
System.out.println("Child thread :"+t);
t.start();
}
public void run()
{
try
{
for(int i=5;i>0;i--)
{
System.out.println("Child Thread:"+i);
Thread.sleep(1000);
}
}
catch(InterruptedException e)
{
System.out.println("Child interrupted.");
}
System.out.println("Exiting child thread");
}
}
class ThreadDemo
{
public static void main(String[] args)
{
new NewThread2();
try
{
for(int i=5;i>0;i--)
{
System.out.println("Main Thread :"+i);
Thread .sleep(1000);
}
}
catch(InterruptedException e)
{
System.out.println("Main thread interrupted.");
}
System.out.println("the main thread exiting");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -