This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi ! I believe the program with print out main, val 1, val 2 in any order depending on if the start() returns and the main() completes execution before the two new threads can execute run(). I am now going to run and check this Ratna
the output cannot be determined because start() returns immediately after the invocation and delegates the job of starting and scheduling the thread to the scheduler. Even if the first ThreadTest is constructed (and started) before the second one, it doesn't mean it will run first. Ratna, it is possible that both newly created threads run before the main thread ends. There is no guarantees as to which thread runs since they all have the same priority and the scheduling is platform-dependent. And the test answer is wrong I'm afraid !!! [ March 18, 2002: Message edited by: Valentin Crettaz ]
the program with print out main, val 1, val 2 in any order
That's what I guessed when looking at the code. Per the quiz, the answer was main, val 1, val 2 in that order. Which is why I'm posting this question. [ March 18, 2002: Message edited by: Mike Cunningham ]
Joined: Nov 14, 2000
I tried it with a for loop. Which validates what both of you just pointed out. Thanks.
Joined: Aug 26, 2001
Mike please indicate which mock this question comes from, after what I'll move this thread to Mock Exam errata. Thanks [ March 18, 2002: Message edited by: Valentin Crettaz ]