public void run() {
for(int i=0;i<60; i++)
{
System.out.println(Thread.currentThread().getName()+"thread run"+i);
Thread.yield();
}
}
两个线程,不是应该间隔输出吗?为什么我的结果都是
Thread-0thread run29
Thread-0thread run30
Thread-0thread run31
Thread-0thread run32
Thread-0thread run33
Thread-0thread run34
Thread-0thread run35
Thread-0thread run36
Thread-0thread run37
Thread-0thread run38
Thread-0thread run39
Thread-0thread run40
Thread-0thread run41
Thread-0thread run42
Thread-1thread run0
Thread-1thread run1
Thread-1thread run2
Thread-1thread run3
Thread-1thread run4
Thread-1thread run5
Thread-1thread run6
Thread-1thread run7
Thread-1thread run8
Thread-1thread run9
Thread-1thread run10
Thread-1thread run11
Thread-1thread run12
Thread-1thread run13
Thread-1thread run14
Thread-1thread run15
Thread-0thread run43
Thread-1thread run16
Thread-0thread run44
Thread-0thread run45
Thread-1thread run17
Thread-0thread run46
Thread-0thread run47
Thread-0thread run48
Thread-0thread run49
Thread-0thread run50
Thread-0thread run51
Thread-0thread run52
Thread-0thread run53
Thread-0thread run54
Thread-0thread run55
Thread-0thread run56
Thread-0thread run57
Thread-0thread run58
Thread-0thread run59
Thread-1thread run18
Thread-1thread run19
Thread-1thread run20
Thread-1thread run21
Thread-1thread run22
Thread-1thread run23
Thread-1thread run24
Thread-1thread run25
Thread-1thread run26
Thread-1thread run27
Thread-1thread run28
Thread-1thread run29
Thread-1thread run30
Thread-1thread run31
Thread-1thread run32
Thread-1thread run33
Thread-1thread run34
Thread-1thread run35
Thread-1thread run36
Thread-1thread run37
Thread-1thread run38
Thread-1thread run39
Thread-1thread run40
Thread-1thread run41
Thread-1thread run42
Thread-1thread run43
Thread-1thread run44
Thread-1thread run45
Thread-1thread run46
Thread-1thread run47
Thread-1thread run48
Thread-1thread run49
Thread-1thread run50
Thread-1thread run51
Thread-1thread run52
Thread-1thread run53
Thread-1thread run54
Thread-1thread run55
Thread-1thread run56
Thread-1thread run57
Thread-1thread run58
Thread-1thread run59这个样式儿的,一个线程都一下子输出那么多呢 |
|