?? thread3.java
字號:
package com.zhoutenghn;
public class Thread3 implements Runnable
{
Thread3a time = new Thread3a();
public static void main(String[] args)
{
// Thread3 thread3a = new Thread3();
Thread3 thread3b = new Thread3();
Thread t3a = new Thread(thread3b);
Thread t3b = new Thread(thread3b);
t3a.setName("t3a");
t3b.setName("t3b");
t3a.start();
t3b.start();
}
public void run()
{
time.add(Thread.currentThread().getName());
}
}
class Thread3a
{
static int num = 0 ;
public synchronized void add (String name )
{
num ++ ;
try
{
Thread.sleep(1000);
}catch (InterruptedException e)
{ }
System.out.println(name+" " +"你是第"+ num +"個訪問的用戶!");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -