java线程池已满后,如何唤醒线程?

如题所述

class ss{
public static int i1=0;
public static int i2=0;
private Object task = new Object();

}

class number extends Thread
{
int m=500;
public static number x1;
// private static Object task = new Object();

public void run()
{
try
{
while(true)
{
sleep(m);
System.out.println(ss.i1);
ss.i1++;
synchronized(this){
if(ss.i1%7==0&&ss.i1%10==7)
{
this.wait();

}
}
}
}
catch(InterruptedException e)
{return;}
}
}

class letter extends Thread
{
int m=500;
String s=new String("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
public void run()
{
try
{
while(true)
{
sleep(m);
System.out.println(s.charAt(ss.i2));
ss.i2++;
if(ss.i2==26)
{
ss.i2=0;
}

}
}
catch(InterruptedException e)
{return;}
}
}

class hello extends Thread
{
int m=5000;
String s2="hello";
public void run()
{
try
{
while(true)
{
sleep(m);
System.out.println(s2);
}
}
catch(InterruptedException e)
{return;}
}
}
public class ex {
public static void main(String[] args)
{
number tr1 =new number();
letter tr2 = new letter(tr1);
hello tr3=new hello();
tr1.start();
tr2.start();
tr3.start();
}
}
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答