线程为何输出两次
有两个线程,为何输出结果为: sdf
aaa
t2
t2
四个输出,应该为两个才是,请大师指点》
public class Tthread extends Thread
{
String msg="sdf";
public void run()
{
try
{
t1.call("aaa");
System.out.println(msg);
t1.sleep(1000);
System.out.println("t2");
t2.sleep(3000);
// System.out.println(Tthread.activeCount());
}
catch(Exception e)
{
}
}
public String call(String msg)
{
this.msg=msg;
return this.msg;
}
static Tthread t1;
static Tthread t2;
public static void main(String[] args)
{
t1=new Tthread();
t2=new Tthread();
t1.start();
t2.start();
}
}