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 advantages of using Java?s layout managers than windowing systems?
What is a void return type?
Can we force the garbage collection to run?
What are loops in java?
Is null a keyword in java?
how many ways we can serialize the java object?
What is the base class of all exception classes?
What is variable and constant explain with example?
Is it possible to compare various strings with the help of == operator? What are the risks involved?
Explain the difference between an object-oriented programming language and object-based programming language?
What are the types of loops in Java, and how are they used?
relation between list and linked list