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

Answer Posted / ajay tiwary

The way you can synchronize the block is:-

synchronized(dummy object)
{
//synchronized statement

}
In dummy object you can use this or u can create a dummy
object by using new Keyword.

What answer Vikki is posted as the first one is not the way
of synchronizing the block but it's a way to synchronizing
a method.

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is inheritance used in java?

830


What is garbage collector?

818


Which java version is latest?

729


What is a nested class?

823


What is parse method?

756


What is run time allocation?

783


What is the range of the short type?

782


How do you trim a space in java?

721


Why do we create threads in java?

804


Can list have duplicates in java?

706


how we can make a write-only class in java?

777


What are the differences between heap and stack memory in java?

766


What do you mean by append?

732


Is null a string in java?

761


What is threaded programming and when is it used? : Java thread

755