Что выведет код?
#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
Что выведет код?
#Tasks
public class Task300725 {
public static void main(String[] args) {
Object lock = new Object();
synchronized (lock) {
try {
lock.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println("Done");
}
}
#Tasks
Что выведет код?
#Tasks
import java.util.concurrent.*;
public class Task310725 {
public static void main(String[] args) throws Exception {
Callable<String> task = () -> "Result";
FutureTask<String> future = new FutureTask<>(task);
new Thread(future).start();
System.out.println(future.get());
}
}
#Tasks
👍2