/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main
(String[] args
) {
final ActionInterrupt interromper = new ActionInterrupt();
final ActionFlag flag = new ActionFlag();
flag.start();
interromper.start();
try {
interromper.interrupt();
flag.setStop();
e.printStackTrace();
}
}
static class ActionInterrupt
extends Thread{ @Override
public void run() {
int pt = 0;
try {
while(true){
System.
out.
println("ActionInterrupt {"+pt
+"}"); pt++;
}
e.printStackTrace();
}
}
}
static class ActionFlag
extends Thread{ private volatile boolean running = true;
public void setStop() {
running = false;
}
@Override
public void run() {
int pt = 0;
while(running){
try {
e.printStackTrace();
}
System.
out.
println("ActionFlag["+pt
+"]"); pt++;
}
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCQkKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKCQkKCQlmaW5hbCBBY3Rpb25JbnRlcnJ1cHQgaW50ZXJyb21wZXIgPSBuZXcgQWN0aW9uSW50ZXJydXB0KCk7CgkJZmluYWwgQWN0aW9uRmxhZyBmbGFnID0gbmV3IEFjdGlvbkZsYWcoKTsKCQlmbGFnLnN0YXJ0KCk7CgkJaW50ZXJyb21wZXIuc3RhcnQoKTsKCQkKCQkJdHJ5IHsKCQkJCVRocmVhZC5zbGVlcCgzMzNMKTsKCQkJCWludGVycm9tcGVyLmludGVycnVwdCgpOwoJCQkJZmxhZy5zZXRTdG9wKCk7CgkJCX0gY2F0Y2ggKEludGVycn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