How the threads are synchronized?

Answers were Sorted based on User's Feedback



How the threads are synchronized?..

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

How the threads are synchronized?..

Answer / dsr

By using wait(),notify and notifyall() methods in the code.

Is This Answer Correct ?    2 Yes 4 No

Post New Answer

More Core Java Interview Questions

Explain the importance of join() method in thread class?

0 Answers  


Where is stringbuffer stored?

0 Answers  


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.

4 Answers   Cap Gemini,


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;

2 Answers  






What is default size of arraylist in java?

0 Answers  


What is style and indentation?

0 Answers  


What is difference between public static and void?

0 Answers  


Explain about fail safe iterators in java?

0 Answers  


How to sort list of list in java?

0 Answers  


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?

3 Answers  


What is a ternary operator in java? What is an interface?

0 Answers  


Categories