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 the advantages of java inner classes?
How many types of design patterns are there?
What do you mean by local variable and instance variable?
Is class is a data type?
Mention a package that is used for linked list class in java.
What is the difference between compile-time polymorphism and runtime polymorphism?
what is the purpose of using rmisecuritymanager in rmi?
Explain the polymorphism principle?
What is protected access modifier?
What is downcasting?
Is main a keyword in java?
5 Coding best practices you learned in java?
what do you mean by classloader?
Why should we use singleton pattern instead of static class?
What are reference variables in java?