Java Language: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 19: Line 19:
=Modifiers=
=Modifiers=


==<span id='synchronized_modifier'></span>synchronized==
==Method Modifiers==
 
===<span id='synchronized_modifier'></span>synchronized===


A <tt>synchronized</tt> class method synchronizes on the monitor associated with the Class object of that class.
A <tt>synchronized</tt> class method synchronizes on the monitor associated with the Class object of that class.


A <tt>synchronized</tt> method synchronizes on the monitor associated with instance it is invoked onto.
A <tt>synchronized</tt> method synchronizes on the monitor associated with instance it is invoked onto.

Revision as of 03:26, 21 March 2018

Internal

Keywords

Statements

synchronized

The synchronized statement acquires a mutual-exclusion lock on behalf of the executing thread, executes a block, then releases the lock. While the executing thread owns the log, no other thread may acquire the lock.

synchronized (expression) block

The type of expression must be a reference type.

Modifiers

Method Modifiers

synchronized

A synchronized class method synchronizes on the monitor associated with the Class object of that class.

A synchronized method synchronizes on the monitor associated with instance it is invoked onto.