Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.concurrent.ExecutorService;
- import java.util.concurrent.Executors;
- import java.util.concurrent.TimeUnit;
- public class Esempio1 {
- public static void main(String[] args) {
- Runnable r = () -> System.out.println("Thread 1");
- ExecutorService executorService = Executors.newSingleThreadExecutor();
- executorService.execute(r);
- System.out.println("Main");
- executorService.shutdown();
- try {
- executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
- } catch (InterruptedException e) { }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement