发布网友 发布时间:2022-04-23 01:57
共2个回答
热心网友 时间:2023-07-12 14:16
public class A extends Thread {
private long times;
public setTimes(long times){
this.times = times ;
}
public A(){}
//或者
// public A(long times){
// this.times = times
// }
public void run{
dosomething
this.sleep(times);
}
public static void main(String[] args) {
A a1 = new A(1000);
A a2 = new A();
a2.setTimes = 2000;
A a3 = new A(3000);
a1.start();
a2.start();
a3.start();
}
}
热心网友 时间:2023-07-12 14:17
在run方法里写上Thread.sleep(时间)不就行了么