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 |
Explain the importance of join() method in thread class?
Where is stringbuffer stored?
What is an exception? difference between Checked and Unchecked exception in Java
0 Answers SkillGun Technologies,
How does marker interface provides functionality to the implemented class ? or How dose maker interface gets the functionalities as serialization or cloning.
10. class Nav{ 11. public enum Direction { NORTH, SOUTH, EAST, WEST } 12. } 13. public class Sprite{ 14. // insert code here 15. } Which code, inserted at line 14, allows the Sprite class to compile? a)Direction d = NORTH; b)Nav.Direction d = NORTH; c)Direction d = Direction.NORTH; d)Nav.Direction d = Nav.Direction.NORTH;
What is default size of arraylist in java?
What is style and indentation?
What is difference between public static and void?
Explain about fail safe iterators in java?
How to sort list of list in java?
This is related to threads. I have a class with synchronized method m1(). Can I create different instances of this class and execute the m1() for different threads?
What is a ternary operator in java? What is an interface?