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...

Can we call the Thread.sleep in Synchyronozed block?

Answer Posted / anmol mathpal

yes u can but be sure to use it under try-catch block.
Actually synchronized keyword is basically used for locking
purpose. let us consider an example:-

/*This is a synchronized block*/
Synchronized(this){
try{Thread.sleep(1000);}catch(InterruptedException e){}
//Remaining code
}
Now suppose there is s thread in a program say A
let us consider thread A enters the synchronized block
because of sleep method it'll take one second more than its
normal execution time.that's it. it will affect other
threads that are waiting for that particular resource.
without thread.sleep method

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference in between java class and bean?

1166


What classes of exceptions may be thrown by a throw statement?

1012


what is function overloading in java?

1366


What is the unit of plancks constant?

1097


Is void a return type?

1021


What is the difference between multiple processes and multiple threads?

1295


What is map in java?

1053


What is java and its types?

1170


Can a class be declared as protected?

1061


What is the difference between abstract class and interface1? What is an interface?

1135


What is the difference between a static and a non-static inner class in java programming?

1144


can java object be locked down for exclusive use by a given thread? Or what happens when a thread cannot acquire a lock on an object? : Java thread

1038


What is final method in java?

1087


What is the primitive type byte?

1045


Implement two stacks using a single array.

1109