希望高手帮忙指点一下,我现在是刚开始学,高手多帮忙啊!
下面是程序代码
public class ThreadDemo9_4
{
public static void main(String[]args)
{
TestThread t=new TestThread();
new Thread(t).start();
new Thread(t).start();
new Thread(t).start();
new Thread(t).start();
}
}
class TestThread implements Runnable
{
private int tickets=20;
public void run()
{
while(true)
{
if(tickets>0)
System.out.println(Thread.currentThread().getName()+"出售票"+tickets--);
}
}
}
下面是程序代码
public class ThreadDemo9_4
{
public static void main(String[]args)
{
TestThread t=new TestThread();
new Thread(t).start();
new Thread(t).start();
new Thread(t).start();
new Thread(t).start();
}
}
class TestThread implements Runnable
{
private int tickets=20;
public void run()
{
while(true)
{
if(tickets>0)
System.out.println(Thread.currentThread().getName()+"出售票"+tickets--);
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货