~/ learn/ java-from-zero/ cards/ Threads & Runnable
1 of 4

Type a Runnable lambda and start it on a new Thread

Type a Runnable lambda and start it on a new Thread

Answer

Thread t = new Thread(() -> System.out.println("hello from thread")); t.start();

new Thread(runnable) creates the Thread object but does not start it. start() actually schedules execution on a new OS thread. The current thread continues immediately after start() returns.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/e5b5d7b5-0da2-43fc-a3dc-0d88be881a61/flashcard utf-8 LF