How the threads are synchronized?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is finally block?

564


Is java 11 paid version?

512


Can list have duplicates in java?

521


What is javac_g?

590


What are the four pillars of java?

608






Explain about the security aspect of java?

568


What is the use of :: in java?

570


Which class contains a method: cloneable or object?

538


What is jar?

631


What is the difference between static binding and dynamic binding?

565


Difference between Linked list and Queue?

604


What are the special characters?

533


Name few java 8 annotations ?

561


What is the final method?

597


Why does the integer quotient -0/3 yield 0, but the double quotient -0.0/3.0 yields – 0.0?

603