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

Discussion

Which one of the following statements about the order in which two started threads execute is true?

  • A.The order in which two started threads execute their statements is not guaranteed.
  • B.Two started threads always execute in the order their start() calls were made.
  • C.Two started threads alternate one statement at a time.
  • D.Two started threads execute in order of their priority values, highest first.

Answer: A

Scheduling is left to the platform, so nothing about relative order is promised and a program that happens to print in a tidy order on one run may not on the next. Any required ordering has to be imposed explicitly, with join, a lock, a latch or a queue.

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

Post your comment

Please log in or register to post a comment.