@Override
public void run() {
for (int i = 0; i < 5; i++) {
System.
out.
println(Thread.
currentThread().
getName() + ": Message " + (i
+ 1)); }
}
public static void main
(String[] args
) { thread.start();
}
}
Y2xhc3MgTXlSdW5uYWJsZSBpbXBsZW1lbnRzIFJ1bm5hYmxlIHsKICAgIEBPdmVycmlkZQogICAgcHVibGljIHZvaWQgcnVuKCkgewogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgNTsgaSsrKSB7CiAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihUaHJlYWQuY3VycmVudFRocmVhZCgpLmdldE5hbWUoKSArICI6IE1lc3NhZ2UgIiArIChpICsgMSkpOwogICAgICAgIH0KICAgIH0KCiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgVGhyZWFkIHRocmVhZCA9IG5ldyBUaHJlYWQobmV3IE15UnVubmFibGUoKSk7CiAgICAgICAgdGhyZWFkLnN0YXJ0KCk7CiAgICB9Cn0=