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
Can we write class inside a class in java?
how can i use a nonsynchronized hashtable?
What is the default value of byte datatype in java?
Explain how can you debug the Java code?
What is subsequence of a string?
Why should we use singleton pattern instead of static class?
what are three ways in which a thread can enter the waiting state? Or what are different ways in which a thread can enter the waiting state? : Java thread
What is a “stateless” protocol ?
What does serializing data mean?
What do you understand by abstract classes?
What is an iterator interface in java programming?
Is minecraft 1.15 out?
Is ruby built on java?
What is thread pool in java with example?
What is the purpose of object oriented programming?