Consecutive threads

  • 4
  • Locked
1. Figure out what the program does. 2. Make the program first display the result of the thread, and when the thread has finished then the main method continues. 3. Example output: inside MyThread 0 inside MyThread 1 ... inside MyThread 9 inside main 0 inside main 1 ... inside main 9
You can't complete this task, because you're not signed in.
Comments (1)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Paul
Level 24 , Vienna, Austria
13 August 2022, 19:39
Question beyond solving this exercise: Can anyone explain to me why in the original exercise "inside main 0" is always displayed first, although t.start(); is called first. I expected that t.start() starts the new thread, therefore the run method is executed, and then the scheduler logic decides, which of the two will execute first.