class A
{
public static void main(String args[])
{
Th a1 = new Th("T1");
Th a2 = new Th("T2");
Th a3 = new Th("T3");
Th a4 = new Th("T4");
Th a5 = new Th("T5");
Th a6 = new Th("T6");
a6.setPriority(9);
a5.setPriority(8);
a4.setPriority(7);
a3.setPriority(9);
a2.setPriority(5);
a1.setPriority(4);
a1.start();
a2.start();
a3.start();
a4.start();
a5.start();
a6.start();
}
}
class Th extends Thread
{
String name;
public Th(String str)
{
name = str;
}
public void run()
{
for(int i=1;i<1000;i++)
System.out.println("系统命名:"+getName() +" 自己命名:"+name+" i的值:"+i*i);
}
}Th a6 = new Th("T6");
这个线程在eclipse内总是不执行,在JcreatOR内是可以的。真是怪了!!!!!大家试试。我已经试了20来次了。
{
public static void main(String args[])
{
Th a1 = new Th("T1");
Th a2 = new Th("T2");
Th a3 = new Th("T3");
Th a4 = new Th("T4");
Th a5 = new Th("T5");
Th a6 = new Th("T6");
a6.setPriority(9);
a5.setPriority(8);
a4.setPriority(7);
a3.setPriority(9);
a2.setPriority(5);
a1.setPriority(4);
a1.start();
a2.start();
a3.start();
a4.start();
a5.start();
a6.start();
}
}
class Th extends Thread
{
String name;
public Th(String str)
{
name = str;
}
public void run()
{
for(int i=1;i<1000;i++)
System.out.println("系统命名:"+getName() +" 自己命名:"+name+" i的值:"+i*i);
}
}Th a6 = new Th("T6");
这个线程在eclipse内总是不执行,在JcreatOR内是可以的。真是怪了!!!!!大家试试。我已经试了20来次了。
改成 public class A
与你自己的name的问题
public class Test
{
public static void main(String args[])
{
Th a1 = new Th("T1");
Th a2 = new Th("T2");
Th a3 = new Th("T3");
Th a4 = new Th("T4");
Th a5 = new Th("T5");
Th a6 = new Th("T6");
a6.setPriority(9);
a5.setPriority(8);
a4.setPriority(7);
a3.setPriority(9);
a2.setPriority(5);
a1.setPriority(4);
a1.start();
a2.start();
a3.start();
a4.start();
a5.start();
a6.start();
}
}
class Th extends Thread
{
public Th(String name){
super(name);
}
public void run()
{
// for(int i=1;i<1000;i++)
System.out.println(getName());
}
}不好意思刚才发重复了,我以为没有发送成功呢
如果你没有给线程起名字的话,jvm会自动给你个名字
不过是从Thred-0开始而已
Thread-5 (T6) 一直没有启动。
而eclipse设置的输出缓冲好像是80000个字符,再多的就显示不出来了
刚开始打印的就被清除了,所以最开始打印的T6看不到
你试着减少循环次数就能看到了
那这是不是eclipse的超级bug ???!!!