本帖最后由 杨兴庭 于 2013-7-16 21:16 编辑
- class Runn1 implements Runnable
- {
- public void run()
- {
- for (int i = 0;i<100 ;i++ )
- {
- System.out.print("*");
- Thread.yield();
- }
- }
- }
- class Runn2 implements Runnable
- {
- public void run()
- {
- for (int i = 0;i<100 ;i++ )
- {
- System.out.print("+");
- Thread.yield();
- }
- }
- }
- public class RunnTest2
- {
- public static void main(String [] args)
- {
- Runn1 r1 = new Runn1();
- Runn2 r2 = new Runn2();
- Thread t1 = new Thread(r1);
- Thread t2 = new Thread(r2);
- t1.start();
- t2.start();
- }
- }
复制代码 为什么运行的结果不是*+*+ 这样有规律的 而运行的结果为什么是没有规律的?
|