Runnable
- Take no value
- Returns no value
Runnable run = () -> System.out.println(“hello”); // compiles
Runnable runBad = () -> “hello”; // doesn’t compile (as returns value)
Remember often classes will implement directly (handy to use constructor to pass values).
Pass a runnable to a Thread (and start it), to get thread functionality. Calling run() method on Runnable alone, doesn’t give Thread functionality p846
ExecutorService.execute(runnable)
same as using passing a runnable to a thread
ExecutorService.submit(runnable / callable)
like execute but abit better returns a Future object (and can also take a Callable )