- package com.isthreadDemo;
- public class TestDemo{
- public static void main (String[]args){
- Test1 t = new Test1();
- Thread t1 = new Thread(t);
- Thread t2 = new Thread(t);
- Thread t3 = new Thread(t);
- Thread t4 = new Thread(t);
- t1.start();
- t2.start();
- t3.start();
- t4.start();
- }
- }
- class Test1 implements Runnable{
- private int ticket;
- public void run(){
- while(true){
- if(ticket>0){
- System.out.println(Thread.currentThread().getName()+"sale:"+(ticket--));
- }
- else{
- break;
- }
- }
- }
- }
复制代码
这段代码为什么在MyEclipse中无法运行啊???编译没有错误。。。
求高人指点啊!!!
谢谢 |
|