|
<a href="http://hyderabaditeducation.com" target="_blank" rel="nofollow">http://hyderabaditeducation.com</a>
SCJA 1.0 (98%), SCJP 1.4 (98%)
SCJP 1.4 (100%) Done.<br />SCJD (URLyBird 1.2.3 Started)
Originally posted by George Bolyuba:
c. The second number printed must always be greater than 5000 - False. Thread a1 will not wait will we leave its start() method. So It might run for 1000 when we will call join() and number will be less then 5000.
SCJA 1.0 (98%), SCJP 1.4 (98%)
George, thread a1 could certainly run for 1000 milliseconds before the main thread calls a1.join(6000), but the second number printed would still have to be greater than or equal to 5000, because the second number printed is the difference between the time before a1.start() was called (startTime), and the time after the a1 thread completed its run method.
SCJP 1.4 (100%) Done.<br />SCJD (URLyBird 1.2.3 Started)
SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD, SCEA/OCMJEA
Live life to an interface, not an implementation!
The A object IS-A thread and it IS-A Runnable. Calling start() will start the new Thread.But how is this actually creating a thread of execution, don�t we have to pass this derived object to the Thread's constructor as a target???
Originally posted by Joe Sanowitz:
because the second number printed is the difference between the time before a1.start() was called (startTime), and the time after the a1 thread completed its run method.
The span of time between the moment before start() was called and the moment after a1's run method completed must be at least 5000 milliseconds because of the call to wait(5000). Therefore answer C is correct.
SCJA, SCJP5.0, SCBCD, SCWCD
Originally posted by reubin nibuer:
Could you tell me why by calling a1.join(6000), the Main thread will not wait at least 6000ms and the option D is not correct?
Waits at most millis milliseconds for this thread to die.
SCJA 1.0 (98%), SCJP 1.4 (98%)
Just let me do the talking. Ahem ... so ... you see ... we have this tiny ad...
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|