BAEL2567-New section on Lombok’s @Getter(lazy=true)
This commit is contained in:
parent
328d58d3d0
commit
79308e6336
|
@ -1,22 +0,0 @@
|
|||
package com.baeldung.loom;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class AsyncThreads {
|
||||
|
||||
public static void main(String[] args) throws ExecutionException, InterruptedException {
|
||||
|
||||
CompletableFuture<Void> cf = CompletableFuture.runAsync(() -> {
|
||||
|
||||
System.out.println("Hello " + Thread.currentThread().getName());
|
||||
});
|
||||
|
||||
cf.thenRun(() -> {
|
||||
|
||||
System.out.println("World " + Thread.currentThread().getName());
|
||||
});
|
||||
|
||||
cf.get();
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package com.baeldung.loom;
|
||||
|
||||
public class BlockingThreads {
|
||||
|
||||
private static final Object LOCK = new Object();
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
|
||||
Thread thread1 = new Thread(() -> {
|
||||
synchronized (LOCK) {
|
||||
System.out.println("Hello " + Thread.currentThread().getName());
|
||||
LOCK.notify();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Thread thread2 = new Thread(() -> {
|
||||
synchronized (LOCK) {
|
||||
try {
|
||||
System.out.println("Will wait for thread1 now...");
|
||||
LOCK.wait();
|
||||
System.out.println("World " + Thread.currentThread().getName());
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
thread2.start();
|
||||
thread1.start();
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue