java thread
来源:百度知道 编辑:UC知道 时间:2024/06/06 04:02:06
经典代码举例
package threadgroup;
class ThreadDemo3 extends Thread {
private String name;
private int delay;
public ThreadDemo3(String sname, int i_delay) {
name = sname;
delay = i_delay;
}
public void run() {
try {
sleep(delay);
} catch (InterruptedException e) {
}
System.out.println("多线程测试!\n" + name + "\n" + delay);
}
}
public class testMyThread {
public static void main(String[] args) {
ThreadDemo3 th1,th2,th3;
th1 = new ThreadDemo3("线程1", (int) (Math.random() * 900));
th2 = new ThreadDemo3("线程2", (int) (Math.random() * 900));
th3 = new ThreadDemo3("线程3", (int) (Math.random() * 900));
th1.start();
th2.start();
th3.start();
}
}
package threadgroup;
public class threadDemo {
public static void m
java Thread 里面的变量能不能访问?
thread main java.lang.NullPointerException Exception in thread main java.lang.NullPointerException
悬赏20:Exception in thread "Thread-3" java.lang.ArrayIndexOutOfBoundsException: -718
Exception in thread "main" java.lang.NoXuchMethodError: main
Exception in thread "main" java.lang.NoClassDefFoundError
java出现错误Exception in thread "main"...
Exception in thread "main" java.lang.NoClassDefFoundError: HelloDate
java多线程的问题?-函数Thread.sleep(3);
Exception in thread "main" java.lang.NoClassDefFoundError:文件名
Exception in thread "main" java.lang.NoClassDefFoundError: Hello