问题:不是建立了四个对象没,tick为什么能够同步?
class threademo implements Runnable
{
private int tick=100;
public void run()
{
while(true)
{
if(tik>0)
System.out.println(this.getName()+"-------------"+tick--);
}
}
}
public static void main()
{
threademo t=new threademo ();
Thread t1=new Thread(t);
Thread t2=new Thread(t);
Thread t2=new Thread(t);
Thread t2=new Thread(t);
t1.start();
t2.start();
t3.start();
t4.start();
}
|
|