~/ learn/ comp-308/ cards/ Threads: Runnable, Thread, and executors
1 of 5

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/4921f4ce-0cf6-45be-82ed-9433d4ccdf22/flashcard utf-8 LF