79113351

Date: 2024-10-22 09:41:29
Score: 2
Natty:
Report link

I am answering this 4 years later, but there is not an accepted answer, and the correct answer is "lost" within a long text. The correct answer is that the ONLY thing that is needed is to insert the code "a.join(); b.join();" right after the call to "b.start();". This will force the main thread of control to wait for the two spawned threads to finish before attempting to read the values in their respective count[] arrays, which will now be correctly visible by the main thread.

Reasons:
  • No code block (0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: Ioannis Christou