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
How many types of methods are there?
What is mean by collections in java?
How do you remove an element from an arraylist in java?
what is the difference between thread and runnable types? : Java thread
Is array synchronized in java?
Who is the owner of java?
What happens when you invoke a thread’s interrupt method while it is sleeping or waiting?
Explain some best practices you would apply while using collection in java?
How is string stored in java?
What is a java lambda expression?
Explain the difference between intermediate and terminal operations in java8?
Write a java program to count the number of words present in a string?
What is getkey () in java?
What is the function of compareto in java?
What is hotjava?