写的线程测试代码,,我用的是myeclipse8 ,按上面的debug按钮时,打印完后有时会出现error(下面红色字) ,有时不会,这是什么问题?
class TTest extends Thread{
TTest(String name){
super(name); //自定义线程名称
}
public void run(){
for (int i = 0; i < 400; i++) {
System.out.println("线程 :"+this.getName()+"运行打印:"+i);
}
}
}
public class ThreadTest {
public static void main(String[] args) {
TTest t=new TTest("one:");
t.start();
TTest t2=new TTest("two:");
t2.start();
new Thread(){
public void run(){
for (int i = 0; i < 200; i++) {
System.out.println("匿名内部类型线程:"+Thread.currentThread().getName());
}
}
}.start();
for (int i = 0; i < 300; i++) {
System.out.println(Thread.currentThread().getName()+"运行打印:"+i);
}
}
}
线程 :one:运行打印:396
线程 :one:运行打印:397
线程 :one:运行打印:398
线程 :one:运行打印:399
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183): [../../../src/share/back/util.c:820] |