public class Test extends Thread{
public static void main(String[] args) {
Test test=new Test();
test.start();
}
public void run(){
boolean time=false;
while(true){
if(time==true){
System.out.println("here");
}else{
System.out.println("come");
}
try {
Thread.sleep(5000);
time=true; //发送信号量
} catch (InterruptedException e) {
System.out.println("线程错误");
e.printStackTrace();
}
}
}
}