what is the difference between yielding and sleeping? : Java thread



what is the difference between yielding and sleeping? : Java thread..

Answer / Wasif Husain

Yielding temporarily gives up CPU time by calling the 'yield()' method in Java. This allows other threads that are ready to execute but not yet running to run instead. Sleeping, on the other hand, suspends a thread for a specified amount of time using the 'sleep()' method. During this time, the thread does not respond to any incoming events or execute any code.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

How many return statement are allowed in a function?

1 Answers  


Where is the singleton class used?

1 Answers   Cap Gemini,


Can we store variables in local blocks?

1 Answers   Global Logic,


ublic class Java_Coding_Samples { public static void JavaHungr(NumberFormatException ae){ System.out.println("integer"); } public static void JavaHungry(Exception e){ System.out.println("string"); } public static void JavaHungry(ArithmeticException ae){ System.out.println("object"); } public static void main(String[] args) { JavaHungry(null); }

1 Answers  


What is type parameter in java?

1 Answers  


In the below example, how many string objects are created?

1 Answers  


What is the difference between stringbuffer and stringbuilder class?

1 Answers  


What advantage do java's layout managers provide over traditional windowing systems?

1 Answers  


Lowest Common ancestor in a Binary Search Tree and Binary Tree.

1 Answers   Amazon,


what is the use of clone method? why user cant overwrite in sub class without its proper defination.

2 Answers   TCS,


How do you sort words in java?

1 Answers  


What do you mean by inner class in java?

1 Answers  


Categories