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
What are static methods?
What value is a variable of the string type automatically initialized?
How many bytes is a string java?
Which keyword specify that a variable is effectively final ?
What does string intern() method do?
Can constructor be synchronized?
Can we execute a program without main() method?
What are the differences between abstract class and interface?
When is the garbage collection used in Java?
How does list work in java?
What is not thread safe?
Which collection does not allow duplicates in java?
What if constructor is protected in java?
Explain creating threads by implementing runnable class?
What about abstract classes in java?