Java 8 Concurrency

(note, for basic concepts, read threading notes)

Threads and Executors

a basic example:

Runnable task = () -> {
    String threadName = Thread.currentThread().getName();
    System.out.println("Hello " + threadName);
};

task.run(); # this one runs on main thread

Thread thread = new Thread(task);
thread.start();

System.out.println("Done!");

output:

Hello main
Hello Thread-0
Done!

Reference

Search Blog: