关于Java中多线程和并行程序设计的问题
如以下代码所展示,请问以下代码有什么错误?
public class Test implements Runnable{
public static void main(String[] args) throws InterruptedException{
new Test();
}
public Test() throws InterruptedException{
Thread thread = new Thread(this);
thread.sleep(1000);
}
public synchronized void run(){}
}
程序没有报错,运行也没有报错,请问代码有什么错误呢?
不太清楚你这个题目的需求是啥,
感觉有问题的地方:
1.你实现的线程任务中run方法没有逻辑体现, 就是你希望这个线程开启以后执行什么操作
2.线程没启动, thread.start();
如果有帮助,辛苦点击采纳,谢谢~
你这相当于啥都没写