日期:2014-05-20 浏览次数:20823 次
class MyThread implements Runnable
{
private int ticket = 10;
public void run()
{
for(int i=0;i<10;i++)
{
if(ticket>0)
{
System.out.println("票数剩余:"+ticket--);
}
}
}
}
public class Demo
{
public static void main(String[] args)
{
MyThread mt = new MyThread();
new Thread(mt).start();
new Thread(mt).start();
new Thread(mt).start();
}
}