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 variables and functions?
Which is better singleton or static class?
Why is string buffer better than string ?
Which of the classes will have more memory allocated?
How many boolean functions are there?
How to split a string in java?
Is string a class?
What happens to the Exception object after handling an exception?
What is collection class in java?
What is difference between equal and == in java?
What is meant by inheritance and what are its advantages?
When to use runnable interface vs thread class in java?
What is sortedset in java?
What is the difference between stringbuffer and stringbuilder?
What is math floor in java?