Java synchronized mechanism: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(2 intermediate revisions by the same user not shown)
Line 9: Line 9:
=Inefficiencies=
=Inefficiencies=


Code written using the <tt>syncrhonized</tt> mechanism is expensive on multicore CPU systems.
Code written using the <tt>syncrhonized</tt> mechanism is expensive on multicore CPU systems, because synchronization forces code to execute sequentially, which works against the goal of [[Parallelism#Overview|parallelism]]. The [[Java_8_Streams_API|Streams API]], introduced in Java 8, removes the need of explicitly using  <tt>syncrhonized</tt>.

Latest revision as of 18:49, 22 March 2018

Internal

Overview

Inefficiencies

Code written using the syncrhonized mechanism is expensive on multicore CPU systems, because synchronization forces code to execute sequentially, which works against the goal of parallelism. The Streams API, introduced in Java 8, removes the need of explicitly using syncrhonized.