还是之前卖票的例子:
class Test implements Runnable
{
private int num = 50;
Object obj = new Object();
public void run ()
{
while (true)
{
if (num >= 0)
{
try
{
Thread.sleep(20);
}
catch (Exception e)
{
// TODO: handle exception
System.out.println(e.toString());
}
System.out.println(Thread.currentThread().getName()+">>"+num--);
}
}
}
}
public class RUNNABLE
{
public static void main (String[] args)