import java.util.Scanner;
public class MonitorTask implements Runnable {
private boolean flag =true;
private String word=null;
public void stopMe(){
this.flag=false;
}
public void sendWord(String word){
this.word=word;
}
@Override
public void run() {
while (flag) {
if (word != null && word.contains("alien")) {
System.out.println(Thread.currentThread().getName() + " found alien in " + word);
}
word = null;
}
System.out.println(Thread.currentThread().getName() + " stop");
}
}
class Main1{
public static void main(String[] args) throws InterruptedException {
Scanner scan=new Scanner(System.in);
MonitorTask monitorTask = new MonitorTask();
Thread t=new Thread(monitorTask);
t.start();
while(true){
String word=scan.next();
if(word.equals("stop")){
monitorTask.stopMe();
break;
}
monitorTask.sendWord(word);
}
}
}