Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Difference between sleep and suspend?

Answers were Sorted based on User's Feedback



Difference between sleep and suspend?..

Answer / vikneswaran

following three method to block the thread
1.sleep()
2.suspend()
3.wait()
sleep() its move to waiting state for particular time
for example
Thread.sleep(3000);
but
suspend() method its move to waiting state until called
resume() method.

Is This Answer Correct ?    18 Yes 2 No

Difference between sleep and suspend?..

Answer / shweta

Thread.sleep() sends the current thread into the "Not
Runnable" state for some amount of time. The thread keeps
the monitors it has aquired -- i.e. if the thread is
currently in a synchronized block or method no other thread
can enter this block or method. If another thread calls
t.interrupt() it will wake up the sleeping thread.
Note that sleep is a static method, which means that it
always affects the current thread (the one that is
executing the sleep method). A common mistake is to call
t.sleep() where t is a different thread; even then, it is
the current thread that will sleep, not the t thread.

t.suspend() is deprecated. Using it is possible to halt a
thread other than the current thread. A suspended thread
keeps all its monitors and since this state is not
interruptable it is deadlock prone.

object.wait() sends the current thread into the "Not
Runnable" state, like sleep(), but with a twist. Wait is
called on a object, not a thread; we call this object
the "lock object." Before lock.wait() is called, the
current thread must synchronize on the lock object; wait()
then releases this lock, and adds the thread to the "wait
list" associated with the lock. Later, another thread can
synchronize on the same lock object and call lock.notify().
This wakes up the original, waiting thread. Basically, wait
()/notify() is like sleep()/interrupt(), only the active
thread does not need a direct pointer to the sleeping
thread, but only to the shared lock object.

Is This Answer Correct ?    11 Yes 0 No

Difference between sleep and suspend?..

Answer / satya

sleep(long millis)

takes a pause for a thread for a time in milli seconds,
after the sleep time is over then the thread is again
executing

suspend()

suspending the running thread

Is This Answer Correct ?    4 Yes 6 No

Post New Answer

More Advanced Java Interview Questions

What you mean by COM and DCOM?

0 Answers  


Difference between swing and awt?

0 Answers  


what is DGC?

1 Answers  


Explain Object Serialization and it can be used?

3 Answers   Infosys,


what is the Scope of Final Keyword in Java?

1 Answers   HCL,


What is the highest-level event class of the event-delegation model?

0 Answers  


function of extends and implements keywords?

2 Answers  


Wt is the main difference between Java and Java J2EE and Advanced java?

5 Answers   Wipro,


What is abstract schema?

0 Answers  


Why won’t the jvm terminate when I close all the application windows?

0 Answers  


What is a convertor?

1 Answers   Suzlon,


What is there in browser that it supports web based applications of java or any other PL?

2 Answers  


Categories