| Author |
Thread Prog...
|
Thangaraj Selvamani
Ranch Hand
Joined: Sep 20, 2008
Posts: 61
|
|
Options Are: 1.It prints 0. 2.It prints 999999. 3.The output is not guaranteed to be any of the above. In Both The Codes Option 2 is correct...why option 3 is not correct Source:
http://nikojava.wordpress.com/2008/09/08/scjp-mock-exam-for-threads/
[ November 01, 2008: Message edited by: Thangaraj Raj ] [ November 01, 2008: Message edited by: Thangaraj Raj ] [ November 01, 2008: Message edited by: Thangaraj Raj ] [ November 01, 2008: Message edited by: Thangaraj Raj ]
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
Thangraj please Quote your source
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Thangaraj Selvamani
Ranch Hand
Joined: Sep 20, 2008
Posts: 61
|
|
ok...Ankit Garg...i have edited the source... please check it...
|
 |
Ninad Kulkarni
Ranch Hand
Joined: Aug 31, 2007
Posts: 774
|
|
Hello Thangaraj Raj In both cases main thread executes wait() on thread object after notify by thread object in case 1 main prints vlue of number in second case answer is here http://www.coderanch.com/t/270321/java-programmer-SCJP/certification/Threads Regards Ninad
|
SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
|
 |
Thangaraj Selvamani
Ranch Hand
Joined: Sep 20, 2008
Posts: 61
|
|
thank you...Ninad Kulkarni...my doubt is cleared... but before " synchronized (thread) { " this line gets execute...new thread is moved from runnable to running state...that time the main thread will be in blocked state for ever...if this happens how the 2nd option is possible... [ November 01, 2008: Message edited by: Thangaraj Raj ]
|
 |
long meng
Ranch Hand
Joined: Oct 10, 2008
Posts: 58
|
|
|
oh yes, in case 1,if the Job(thread) run first,and after it complete,after that the main thread run,so will the main thread wait forever?
|
SCJP 5.0 98%<br />SCWCD 5.0 in progress . . .
|
 |
Tuna Töre
Ranch Hand
Joined: Aug 17, 2008
Posts: 219
|
|
main thread waits forever...
|
blog: http://tunatore.wordpress.com
SCJP 6.0 + SCWCD 1.5
|
 |
long meng
Ranch Hand
Joined: Oct 10, 2008
Posts: 58
|
|
|
so Anut Walidera ,if the main thread waits forever,then the main thread won't print anything out,so the answer should be "3.The output is not guaranteed to be any of the above."
|
 |
 |
|
|
subject: Thread Prog...
|
|
|