原文連結:http://blog.csdn.net/wu_lai_314/article/details/8655585
如有侵權,請作者聯系我删除部落格,謝謝
//僅作為學習筆記
class Tick implements Runnable
{
private int tick = 50;
public void run()
{
while(true)
{
if(tick > 0)
System.out.println( Thread.currentThread().getName() + " sail --" + tick--);
}
}
}
class TickDemo
{
public static void main(String []args)
{
Tick t = new Tick();
Thread t1 = new Thread(t);
Thread t2 = new Thread(t);
Thread t3 = new Thread(t);
Thread t4 = new Thread(t);
t1.start();
t2.start();
t3.start();
t4.start();
}
}