Which statement correctly creates a Java thread from a class that implements Runnable and starts it running?

Java Programming Threads Difficulty: Easy
Choose an option
  • A
    new Runnable(MyRunnable).start();
  • B
    new Thread(MyRunnable).run();
  • C
    new Thread(new MyRunnable()).start();
  • D
    new MyRunnable().start();

Answer

Correct Answer: new Thread(new MyRunnable()).start();

Explanation

Introduction / Context:There are two common ways to create threads in Java: extend Thread or implement Runnable. This question focuses on the Runnable approach.

Given Data / Assumptions:

  • MyRunnable implements Runnable and overrides run().

Concept / Approach:To execute a Runnable on a new thread, wrap the Runnable in a Thread and call start() on the Thread instance.

Step-by-Step Solution:

1) Construct a Thread with the Runnable: new Thread(new MyRunnable()).2) Call start() to spawn the new thread; the JVM then calls run() on that thread.

Verification / Alternative check:Calling run() directly executes on the current thread, not a new one.

Why Other Options Are Wrong:

  • Option A → invalid constructor call; Runnable is an interface, not a constructor parameter like that.
  • Option B → calls run() directly on the new Thread object constructed with a type token (also invalid usage).
  • Option D → Runnable has no start() method.

Common Pitfalls:Confusing start() with run() and trying to call start() on a Runnable instead of a Thread.

Final Answer:new Thread(new MyRunnable()).start();

Discussion & Comments
No comments yet. Be the first to comment!
Join Discussion