例子:
class Ticket implements Runnable//extends Thread
{
private int tik=100;
public void run()
{
while (true)
{
if (tik>0)
{
System.out.println(Thread.currentThread().getName()+"..."+tik--);
}
}
}
}
class ThreadTest2
{
public static void main(String[] args)
{
Ticket t = new Ticket();
Thread t1 = new Thread(t);
Thread t2 = new Thread(t);
Thread t3 = new Thread(t);
Thread t4 = new Thread(t);