How the threads are synchronized?
Answers were Sorted based on User's Feedback
Answer / seshadri pera
Threads are synchronized in two ways.
1) block level
2) Method level
Block level synhronization is the better performance
compare to method level.
Block Level:
see the code syntax for block level
synchronized {..
....//code to lock the specific object here..
...}
Method Level:
See the syntax
public void synchronized XXXMethodName(Parameters or
object to acquire locking){.....
...}
Is This Answer Correct ? | 7 Yes | 1 No |
Answer / dsr
By using wait(),notify and notifyall() methods in the code.
Is This Answer Correct ? | 2 Yes | 4 No |
What are the different ways of creating thread?
What is the use of optional ?
What is default exception handling in java?
Tell me a few examples of final classes defined in Java API?
why Interface used?
What is the role of the java.rmi.naming class?
What is string [] java?
What is java objectoutputstream?
How do you add an element to a set in java?
Catch(Exception e){ } in that what is Exception and purpose of that in that place exactly?
What super () does in java?
What are the special characters?