【注意】Win下的类名……
由于Win下的文件名不区分大小写,所以如果同一个包中有相同的类(比如下例中的TestThread类和testthread),就无法通过编译。
软院的一个同学发来一个貌似无错的程序,跑了一下才发现原来如此……
-
private String whoami;
-
private long delay;
-
//Our constructor to store the name (whoami) and time to sleep (delay)
-
whoami = s;
-
delay = d;
-
}
-
//Run - the thread method similar to main() When run is finished, the thread dies.
-
//Run is called ** the start() method of Thread
-
@Override
-
public void run() {
-
//Try to sleep for the specified time
-
try {
-
sleep(delay);
-
} //Now print out our name
-
}
-
}
-
/** * Multimtest. A simple multithread thest program */
-
public class testthread {
-
TestThread t1, t2, t3; //Create our test threads
-
t1 = new TestThread("Thread1", 1000);
-
t2 = new TestThread("Thread2", 2000);
-
t3 = new TestThread("Thread3", 3000);
-
//Start each of the threads
-
t1.start();
-
t2.start();
-
t3.start();
-
}
-
}
- 无匹配