和毕老师的创建线程代码一样,但是没有老师那种交替抢占CPU资源的效果,为什么...求解(我用的是myeclipse8.5编译的,是不是我这个集成环境有问题呀?)- class test extends Thread{
- public void run(){
- for(int i=0; i<60; i++){
- System.out.println("test run..."+i);
- }
- }
- }
- public class ThreadDemo {
- public static void main(String[] args){
- test t = new test();
- t.start();
- for(int i = 0;i < 60; i++){
- System.out.println("main run..."+i);
- }
- }
- }
复制代码 下面是我的允许结果:
main run...0
main run...1
main run...2
main run...3
main run...4
main run...5
main run...6
main run...7
main run...8
main run...9
main run...10
main run...11
main run...12
main run...13
main run...14
main run...15
main run...16
main run...17
main run...18
main run...19
main run...20
main run...21
main run...22
main run...23
main run...24
main run...25
main run...26
main run...27
main run...28
main run...29
main run...30
main run...31
main run...32
main run...33
main run...34
main run...35
main run...36
main run...37
main run...38
main run...39
main run...40
main run...41
main run...42
main run...43
main run...44
main run...45
main run...46
main run...47
main run...48
main run...49
main run...50
main run...51
main run...52
main run...53
main run...54
main run...55
main run...56
main run...57
main run...58
main run...59
test run...0
test run...1
test run...2
test run...3
test run...4
test run...5
test run...6
test run...7
test run...8
test run...9
test run...10
test run...11
test run...12
test run...13
test run...14
test run...15
test run...16
test run...17
test run...18
test run...19
test run...20
test run...21
test run...22
test run...23
test run...24
test run...25
test run...26
test run...27
test run...28
test run...29
test run...30
test run...31
test run...32
test run...33
test run...34
test run...35
test run...36
test run...37
test run...38
test run...39
test run...40
test run...41
test run...42
test run...43
test run...44
test run...45
test run...46
test run...47
test run...48
test run...49
test run...50
test run...51
test run...52
test run...53
test run...54
test run...55
test run...56
test run...57
test run...58
test run...59
|
|