2 Answers - Sort by: Date | Rating
As we know java programming language supports multi threading concept. The threads are running at the same time if you want to stop execution of a thread and give the control to another thread these two functions, are supported by java for the purpose
Wait() : This function takes parameters as milliseconds and puts the thread in wait state for the desired time of the programmer after time passes the execution starts again.
Sleep() : This function is also used for same purpose using his function by java you can put a thread in sleep state .sleep does not contains any parameters so the thread will not be automatically start execution It needs a wake up signal again which can be Notify().or other function are also provided by java.
So the main difference in Wait() and sleep() is wait takes time parameter and wait for specific time only and sleep throws a thread in sleep mode for unspecified time.
Wait() : This function takes parameters as milliseconds and puts the thread in wait state for the desired time of the programmer after time passes the execution starts again.
Sleep() : This function is also used for same purpose using his function by java you can put a thread in sleep state .sleep does not contains any parameters so the thread will not be automatically start execution It needs a wake up signal again which can be Notify().or other function are also provided by java.
So the main difference in Wait() and sleep() is wait takes time parameter and wait for specific time only and sleep throws a thread in sleep mode for unspecified time.
1
0
your answer is very nice
You have to brush up java once again, it's making wrong path for new to the field
Thank you for clear explanation
Wait waits till the other process is completed or a revoke(not sure about the method's name) is called,while sleep sleeps for the specified amount of period.
0
0
- How To Update The Sim 3 Expansion?
- What Is An Attribute In Java?
- Do I Have To Write A Main Method In Every Class I Create?Why?
- Do I Have To Write A Main Method In Every Class I Create?
- What How The Step For Make Library Management?
- In Which Process We Can Start Java?
- Define The Concept Of Java Byte Code?
- How To Run Remote Method Invocation In More Machine?
- How To Run Java Remote Method Invocation In More Machine?
- How To Make A Java Program That Will Ask The User To Input A Number And Display All The Even Number And The Sum Of All Even Numbers Based On The Inputted/ Given Numbers?
- Is A Static Variable An Instance?
- How To Compile And Run Java Package?
- What Does Literati-on Mean?
- What Is Abstract Class In Details?
- What Is Meant By Remote Method Invocation In Java?
- What Is Meant By Servlet In Java?
- What Is Latest Technologies In Java?
- Write A Program Using Do…..while Loop To Calculate And Print The First M Fibonacci Numbers?
- What Is The Difference Between Reference &instance Variable?
- Why Java Is Slow?
- What Is The Drawback Of Ms Access?
- What Is Replaced In Place Of Pointers In Java?
- What Replaces Pointers In Java?
- How Many Types We Create Object In Java?
- I Signed Up Promo Code 505124 For 12 Months My Bill Said For 6 Months Who Fix This Error?
- Why Is The Sleep Method Given As Static In The Thread Class In Java?
- What Is The Difference Between C, C++ And Java?
- What Is The Difference Between C,c++,java?
- What Is The Difference Between Java And J2ee?
- What Is The Actual Difference Between Java And C++?
- What Is The Difference Between .net And Java?
- What's The Difference Between Java And .net?
- What Is The Difference Between C Language And Java Language?
- What Is The Difference Between C, C++ And Java Languages?

New Comment - Comments are editable for 5 min.