Java Language: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
No edit summary
Line 17: Line 17:
The type of ''expression'' must be a reference type.
The type of ''expression'' must be a reference type.


{{Internal|Java synchronized mechanism#Overview|'synchronized' mechanism}}
Also see: {{Internal|Java synchronized mechanism#Overview|'synchronized' mechanism}}


=Modifiers=
=Modifiers=
Line 29: Line 29:
A <tt>synchronized</tt> instance method synchronizes on the monitor associated with <tt>this</tt> - the object instance it is invoked onto.
A <tt>synchronized</tt> instance method synchronizes on the monitor associated with <tt>this</tt> - the object instance it is invoked onto.


{{Internal|Java synchronized mechanism#Overview|'synchronized' mechanism}}
Also see: {{Internal|Java synchronized mechanism#Overview|'synchronized' mechanism}}

Revision as of 03:35, 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.

Also see:

'synchronized' mechanism

Modifiers

Method Modifiers

synchronized

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

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

Also see:

'synchronized' mechanism