java中怎么开启一个线程
收起
云计算小粉
2018-05-10 20:09:22
2540
0
2
条回答
写回答
取消
提交回答
-
1、继承Thread类,假设类A继承Thread
A myThread = new A();
myThread.start();
2、实现Runnable接口,假设类A实现runnable接口
A myRunnable = new A();
Thread myThread = new Thread(myRunnable);
myThread.start();
2019-07-17 22:18:56
-
Thread t = new Thread(
new Runnable(){
@override
public void run(){
//your code
}
}
).start();
2019-07-17 22:18:56