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

What are the different ways of creating thread?

0 Answers  


What is the use of optional ?

0 Answers  


What is default exception handling in java?

0 Answers  


Tell me a few examples of final classes defined in Java API?

0 Answers   DELL,


why Interface used?

0 Answers   HCL,






What is the role of the java.rmi.naming class?

0 Answers  


What is string [] java?

0 Answers  


What is java objectoutputstream?

0 Answers  


How do you add an element to a set in java?

0 Answers  


Catch(Exception e){ } in that what is Exception and purpose of that in that place exactly?

3 Answers  


What super () does in java?

0 Answers  


What are the special characters?

0 Answers  


Categories