Что выведет код?
#Tasks
import java.util.concurrent.*;
public class Task280725 {
public static void main(String[] args) throws Exception {
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<String> future = executor.submit(() -> {
Thread.sleep(1000);
return "Done";
});
System.out.println(future.get(500, TimeUnit.MILLISECONDS));
executor.shutdown();
}
}
#Tasks
🔥2
Что выведет код?
#Tasks
public class Task290725 {
public static void main(String[] args) {
Object lock1 = new Object();
Object lock2 = new Object();
new Thread(() -> {
synchronized(lock1) {
synchronized(lock2) {
System.out.println("Thread 1");
}
}
}).start();
new Thread(() -> {
synchronized(lock1) {
synchronized(lock2) {
System.out.println("Thread 2");
}
}
}).start();
}
}
#Tasks
👍1