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

What are the two ways you can synchronize a block of code?

Answer Posted / vikki

There are two ways to syanchronize access to an object

1st one is using synchronized keyword for example

Synchronized type methodname(arg-list)
{
//synchrinized method body
}

2nd way s using synchronized block

synchronized(object)
{
//synchronized statement

}

Is This Answer Correct ?    30 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are static methods?

1104


What value is a variable of the string type automatically initialized?

1162


How many bytes is a string java?

1072


Which keyword specify that a variable is effectively final ?

1044


What does string intern() method do?

1132


Can constructor be synchronized?

985


Can we execute a program without main() method?

1084


What are the differences between abstract class and interface?

1154


When is the garbage collection used in Java?

1258


How does list work in java?

963


What is not thread safe?

1036


Which collection does not allow duplicates in java?

1026


What if constructor is protected in java?

1193


Explain creating threads by implementing runnable class?

1235


What about abstract classes in java?

1105