ANSWERS: 2
  • Is your processor capable of running simultaneous threads? That could be the problem. Also, how long is the program? It could be that there is an exit call in the "a" thread that the processor reaches before it executes the contents of the "b" thread. What processor do you have?
  • You need to look at what happens in a.run(). In many Thread Objects, the run() method is a loop which will not terminate until some condition is met. Normally you do not call the run() method yourself. You would normally call start(), which will then call the run() method as a different Thread. if you call a.start(); b.start() the two will happen in parallel.

Copyright 2023, Wired Ivy, LLC

Answerbag | Terms of Service | Privacy Policy