Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of these are legal Thread constructors?

  • A.Thread(String) and Thread(int stackSize) only
  • B.Thread(), Thread(Runnable) and Thread(Runnable, String)
  • C.Thread(), Thread(Runnable) and Thread(int priority)
  • D.Thread(Runnable) and Thread(long id) only

Answer: B

Thread offers a no-argument form, one taking a Runnable, one taking a name, and combinations of Runnable, name and ThreadGroup. Neither priority nor id is a constructor argument: priority is set afterwards with setPriority, and the id is assigned by the JVM and only readable.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.