【发布时间】:2018-12-16 17:48:03
【问题描述】:
1- package demotest;
2- public class thread_example1 implements Runnable {
3- @Override
4- public void run() {
5- }
6- public static void main(String[] args) {
7- Thread guruthread1 = new Thread();
8- guruthread1.start();
9- try {
10- guruthread1.sleep(1000);
11- } catch (InterruptedException e) {
12- // TODO Auto-generated catch block
13- e.printStackTrace();
14- }
15- guruthread1.setPriority(1);
16- int gurupriority = guruthread1.getPriority();
17- System.out.println(gurupriority);
18- System.out.println("Thread Running");
19- Process proc = rt.exec("mspaint");
20- Thread.sleep(5000);
21- proc.destroy();
22- }
23- }
第 7 行和第 20 行有什么区别?在这两种情况下线程都会暂停吗?他们做的任务和我说的一样吗?
I have this schedule :
Operation Line Number
Execution Paused 10 and 20
Start Execution 8
Closing Child Process 21
Thread Creation 7
Execution of Child Process 19
Adjusting Priority 15
Reading Priority 16
还有更多的行吗?例如,在执行暂停时,我们有 2 行。难道其他操作也不止一条线?
另外,我的答案是否正确。
【问题讨论】:
标签: multithreading operating-system runnable thread-sleep