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

Discussion

Which of these correctly names a thread at construction time?

  • A.new Thread(task, 'worker')
  • B.new Thread(task, "worker")
  • C.new Thread("worker", task)
  • D.new Thread(task).name("worker")

Answer: B

The two-argument constructor takes the Runnable first and the name second. There is no builder-style name method, and single quotes make a char literal rather than a String. setName can also be used after construction.

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

Post your comment

Please log in or register to post a comment.