~/ learn/ comp-308/ cards/ Concurrency
1 of 27

Type the Runnable-plus-Thread launch pattern (note: start(), not run())

Type the Runnable-plus-Thread launch pattern (note: start(), not run())

Answer

Runnable task = () -> System.out.println("running"); Thread t = new Thread(task); t.start(); // NOT t.run()

A lambda supplies run(). start() spawns a new thread that calls run(); t.run() would execute on the current thread with no concurrency.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/822b5f74-bc3d-4a47-9447-a8f9b68d9472/flashcard utf-8 LF