/* package whatever; // don't place package name! */
public class Main {
private static Thread criarThread
(final int numero
) { @Override
public void run() {
try {
System.
out.
println("t" + numero
+ " começou"); System.
out.
println("t" + numero
+ " terminou"); // Ignora...
}
}
});
}
public static void main
(String[] args
) { criarThread(1),
criarThread(2),
criarThread(3),
criarThread(4),
criarThread(5)
};
t.start();
}
try {
t.join();
// Ignora...
}
}
System.
out.
println("Todas as threads terminaram"); }
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKcHVibGljIGNsYXNzIE1haW4gewoKICAgIHByaXZhdGUgc3RhdGljIFRocmVhZCBjcmlhclRocmVhZChmaW5hbCBpbnQgbnVtZXJvKSB7CiAgICAgICAgcmV0dXJuIG5ldyBUaHJlYWQobmV3IFJ1bm5hYmxlKCkgewogICAgICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgICAgcHVibGljIHZvaWQgcnVuKCkgewogICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oInQiICsgbnVtZXJvICsgIiBjb21lw6dvdSIpOwogICAgICAgICAgICAgICAgICAgIFRocmVhZC5zbGVlcCgoaW50KSAoTWF0aC5yYW5kb20oKSAqIDEwMDAwKSk7CiAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJ0IiArIG51bWVybyArICIgdGVybWlub3UiKTsKICAgICAgICAgICAgICAgIH0gY2F0Y2ggKEludGVycnVwdGVkRXhjZXB0aW9uIGUpIHsKICAgICAgICAgICAgICAgICAgICAvLyBJZ25vcmEuLi4KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0pOwogICAgfQoKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKICAgICAgICBUaHJlYWRbXSB0cyA9IHsKICAgICAgICAgICAgY3JpYXJUaHJlYWQoMSksCiAgICAgICAgICAgIGNyaWFyVGhyZWFkKDIpLAogICAgICAgICAgICBjcmlhclRocmVhZCgzKSwKICAgICAgICAgICAgY3JpYXJUaHJlYWQoNCksCiAgICAgICAgICAgIGNyaWFyVGhyZWFkKDUpCiAgICAgICAgfTsKICAgICAgICBmb3IgKFRocmVhZCB0IDogdHMpIHsKICAgICAgICAgICAgdC5zdGFydCgpOwogICAgICAgIH0KICAgICAgICBmb3IgKFRocmVhZCB0IDogdHMpIHsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIHQuam9pbigpOwogICAgICAgICAgICB9IGNhdGNoIChJbnRlcnJ1cHRlZEV4Y2VwdGlvbiBlKSB7CiAgICAgICAgICAgICAgICAvLyBJZ25vcmEuLi4KICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIlRvZGFzIGFzIHRocmVhZHMgdGVybWluYXJhbSIpOwoJfQp9