This is the final article in this series of “Effective Java – Key Points”. Let’s jump into the points.

  1. Synchronization is required for reliable communication between threads as well as for mutual exclusion. Synchronization will not have effect unless both read and write are synchronized.
  2. If only inter-thread communication is required and not mutual exclusion, then volatile modifier can be used.
  3. Avoid excessive synchronization. Never call an alien method from a synchronized region, to avoid any deadlock or data corruption as an alien method are designed to be subclassed and the API will never know what the implementation of those methods is.
  4. Never use newCachedThreadPool in a highly loaded environment because it as good as creating as many threads as requested. It is ideal to use newFixedThreadPool which could be optimized based on the server capacity.
  5. Lazy initialization holder class idiom and Double check idiom should be used in case of lazy initialization of threaded environment.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s