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 math in java?

568


What is nan inf?

507


Why do people says “java is robust”?

560


Can I declare class as static or private?

545


How to display arraylist values in java?

490






Can we inherit inner class?

523


What’s the difference between applets and standalone program?

534


who can i handle multiple client in RMI

1443


Why is string class considered immutable?

598


What is null object in java?

572


What is a modifier?

873


What is the basic concepts of OOPS?

691


What is string args [] in java?

540


What is a heavyweight component?

542


What is string syntax?

549