~/ 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/e7932c93-b1e8-4e8f-8704-ad687296b92b/flashcard utf-8 LF