• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 408
  • Last Modified:

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.
0
gudii9
Asked:
gudii9
  • 3
1 Solution
 
objectsCommented:
Because it operates on the current thread. Only the currently running thread can be told to yield.
0
 
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
0
 
objectsCommented:
the target thread is the one you want to put to sleep
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now