🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Java Multithreading: all 10 questions

Quiz: Java Multithreading · Question 6 of 10

What does this print? (code)

What does this print?

public class Main {
    public static void main(String[] args) {
        Thread t = new Thread(() -> System.out.println(Thread.currentThread().getName()), "worker");
        t.run();
    }
}
  1. A.worker
  2. B.main
  3. C.Thread-0
  4. D.Nothing
Answer & explanation

Correct answer: main

run() is a normal method call, so the code runs in the current thread (main). Only start() creates the new thread named "worker".

Can you get the rest right without peeking?

Take the timed Quiz: Java Multithreading quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →