Java Language: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 9: Line 9:
* <tt>synchronized</tt> ([[#synchronized_statement|statement]] and [[#synchronized_modifier|modifier]])
* <tt>synchronized</tt> ([[#synchronized_statement|statement]] and [[#synchronized_modifier|modifier]])


==Literals==
===Statements===
 
==Operators==


=Statements=
====<span id='synchronized_statement'></span>synchronized====
 
==<span id='synchronized_statement'></span>synchronized==


The <tt>synchronized</tt> 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.
The <tt>synchronized</tt> 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.
Line 25: Line 21:
Also see: {{Internal|Java synchronized mechanism#Overview|'synchronized' mechanism}}
Also see: {{Internal|Java synchronized mechanism#Overview|'synchronized' mechanism}}


=Modifiers=
===Modifiers===


==Method Modifiers==
====Method Modifiers====


===<span id='synchronized_modifier'></span>synchronized===
=====<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.
Line 37: Line 33:
Also see: {{Internal|Java synchronized mechanism#Overview|'synchronized' mechanism}}
Also see: {{Internal|Java synchronized mechanism#Overview|'synchronized' mechanism}}


===default===
=====default=====
 
 
 
 
 
 
==Literals==
 
==Operators==


=Interface=
=Interface=

Revision as of 19:07, 22 March 2018

Internal

Lexical Structure

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
default

Literals

Operators

Interface

An interface groups related methods together into a contract.

Class

Anonymous Class

Can be used for behavior parameterization.

Abstract Class