Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

thread yield

>>Which of the following statements are true?

1) A higher priority Thread will prevent a lower priorty Thread from getting any access to the CPU.

2) The yield method only allows any higher priority priority thread to execute.

3) The Thread class has a static method called yield

4) Calling yield with an integer parameter causes it to yield for a specific time.

Answer:


3) The Thread class has a static method called yield

A call to yield can allow any waiting thread to execute depending on the scheduling system of the underlying operating system. There is no version of yield that takes an integer parameter. Weather a higher priority thread gets CPU time than a lower priority thread is platform dependent and cannot be certain.





I read above question and answer. It is not clear to me. Why the yield method of thread class is static where as other methods of thread are not static,





Any ideas, resources, links, sample code highly appreciated. thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

i was reading the link

>>>But if another thread were able to invoke sleep on this thread, it would have no way of knowing what section of code was being executed, and whether or not it's a good time for it. In general, it's better to have threads put themselves to sleep. If you want one thread to be able to tell another to go to sleep, you need to devise a means of communication between the threads, and have the target thread check periodically to see if it's been requested to go to sleep.

which one is target thread. please advise
the target thread is the one you want to put to sleep