Q25. If  two threads having different priority then which thread will get chance first for execution?
Ans. If two threads having different priority then the Thread which is having highest priority will get chance first for execution.

Q26 .How we can prevent a thread from execution?
Ans. We can prevent a Thread from executin by using the following methods:

  1. Yield()
  2. Join()
  3. Sleep()

Q27. What is yield() method? Explain its purpose?
Ans.   yield() method causes the current executing thread to pause execution and give the chance for waiting thread are same priority. If there is no waiting thread or all the remaining waiting thread have low priority then the same thread will get chance once again for execution. The Thread which is yielded when it will get chance once again for execution depends upon mercy of Thread scheduler.Public static native void yield();
                             
Q28.What is purpose of join() method?
Ans.  If a Thread wants to wait until some other Thread completion then we should go for join() method.
         Example: if a Thread t1 execute t2.join() ; then t1 will entered into waiting state until t2 Thread completion.