aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads" Watch "Threads" New topic
Author

Threads

Smitha Ballikar
Ranch Hand

Joined: Aug 02, 2005
Posts: 99
The following is part of the code for an application that will run two time consuming processes in two Threads. We want to be sure that all threads get a chance to run. Which statement at line 9 will accomplish this?

Here answer is A,D
THe answer is not C.The reason given is because the class does not extend thread . Does that mean that if a class does not extend thread and implements runnable we cannot use yield() directly.I thought its because its static..
What is the concept here??

Cheers
Smitha
[ August 24, 2005: Message edited by: Barry Gaunt ]
vijaya bacina
Ranch Hand

Joined: Aug 23, 2005
Posts: 155
hi
when u use yield();
the call to the method is implicitly like
this.yeild();
and runnable interface has no methods like yeild() and ur class didn't provide any method by name yeild()
so u get a compiler error says the method yeild is undefined for Testxx class
Smitha Ballikar
Ranch Hand

Joined: Aug 02, 2005
Posts: 99
Hi vijaya,

Thanks for all your answers!!



Regards
Smitha
Shivani Chandna
Ranch Hand

Joined: Sep 18, 2004
Posts: 380
suppose it had Thread.sleep(1000); then why this method call wd not help in ensuring the threads get a chance to run??


/** Code speaks louder than words */
raghu babu
Ranch Hand

Joined: Jul 05, 2005
Posts: 60
sleep method should be between a try-catch block as it throws InterruptedException. But, the options given doesn't show that
sleep is coded between try-catch block.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Threads