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.


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.
Who is Participating?
objectsConnect With a Mentor Commented:
Because it operates on the current thread. Only the currently running thread can be told to yield.
gudii9Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.