class Ticked /*extends Thread*/ implements Runnable
{
private int tick=100;
/*Ticked(String name)
{
super(name);
}*/
public void run()
{
while(true)
{
if(tick>0)
System.out.println(Thread.currentThread().getName()+"....sale"+tick--);
}
}
}
class TickedDemo
{
public static void main(String[] args)
{
Ticked t=new Ticked(/*"卖票"*/);
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();
}
}
这段代码 我想要自己设置线程的名称 如何实现?注释那部分是我自己瞎搞的 可以忽略
求各路大神指点 |
|