Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Threads

 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which method is used to perform interthread communication
A yield()
B sleep()
C notify()
D wait()

Answer it says is yield . with explanation
A yield() call is designed to let the other threads with same priority take their turn, although there is no guarantee that this will happen.

Mine question is why not wait, notify
 
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gaurav Gambhir,

The question asking for "Inter thread communication"
and answer shown for "Thread time slicing".


If the Question is for Inter Thread Communication:
1.As you pointed out correctly inter Thread communication can be established with wait and notify. (guaranteed)

2.join(guaranteed) - which will let the current thread wait on percular thread to end.
A.join(B); A waits until B finishes.


If the Question is for Time slicing:

Then answer should be guaranteed behavior which can only be sleep.
The yield is not guaranteed.

So The Author of this question confused.
 
The happiness of your life depends upon the quality of your thoughts -Marcus Aurelius ... think about this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic