- package com.Painter.Thread;
- public class RunnableDemo1 {
- public static void main(String[] args)
- {
- Test2 test2 = new Test2();
- Thread t1 = new Thread(test2);
- Thread t2 = new Thread(test2);
- Thread t3 = new Thread(test2);
- Thread t4 = new Thread(test2);
- t1.start();
- t2.start();
- t3.start();
- t4.start();
- }
- }
- class Test2 implements Runnable
- {
- private int num=100;
- public void run()
- {
- while (true)
- {
- if(num>0)
- System.out.println(Thread.currentThread().getName()+"="+num--);
- }
- }
- }//我上面定义了四个线程 为何输出时只输出一个 哪里出错了
复制代码
|
|