public void fun(int threadCount) {//here, argument threadCount is 2
while(threadCount-->0)
new Thread() {
public void run() {
while(true) {
this.sleep(3000);
System.out.println("");
}
}
}
}

解决方案 »

  1.   

    一楼的你看懂楼主要说什么了吗,我怎么也看不懂.总觉得少了个标点,但没标点也行.
    到底在类B里实现类A呢,还是类A,类B各有一个线程呢,@#$%^&*()
      

  2.   

    import java.util.*;
    import java.lang.Thread;public class test{
    public static void main(String[] args) throws Exception{
    new B().run();
    }
    };class B extends Thread{
    private String flag ;
    B(){}
    B(String flag){
    this.flag = flag;
    }
    public void run(){
    try{
    new A("1").start();
    this.sleep(3000);
    new A("2").start();
    }catch(Exception e){
    }
    }
    };class A extends Thread{
    private String flag ;
    A(String flag){
    this.flag = flag;
    }
    public void run(){
    while(1==1){
    try{
    this.sleep(6000);
    System.out.println(flag);
    }catch(Exception e){
    }
    }
    }};
    不知这样行不??