{"id":391,"date":"2011-03-10T08:20:00","date_gmt":"2011-03-10T08:20:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/the-dreaded-double-checked-locking-idiom-in-java.html"},"modified":"2012-10-24T14:16:09","modified_gmt":"2012-10-24T14:16:09","slug":"dreaded-double-checked-locking-idiom-in","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html","title":{"rendered":"The dreaded double checked locking idiom in Java"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">The issue discussed in this article is not new, but still tricky even for seasoned developers.&nbsp;The <a href=\"http:\/\/en.wikipedia.org\/wiki\/Singleton_pattern\">singleton pattern<\/a> is a common programming idiom. Nevertheless when used with multiple threads, some type of synchronization&nbsp;must be done in order not to break the code.<\/p>\n<p>In <a href=\"http:\/\/khangaonkar.blogspot.com\/2010\/02\/dreaded-double-check-pattern-in-java.html\">a relevant article<\/a> our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG<\/a> partner Manoj Khangaonkar from <a href=\"http:\/\/khangaonkar.blogspot.com\/\">The Khangaonkar Report<\/a>&nbsp;examines the double-checked locking idiom in detail to understand just where it breaks down and presents all possible solutions :<\/p>\n<p>Lest see what he has to say :<\/p>\n<p>The problem with double check locking in java is well documented. Yet even a seasoned programmer can get overzealous trying to optimize synchronization of code that creates singletons and fall prey to the trap.<\/p>\n<p>Consider the code<\/p>\n<pre class=\"brush:java\">public class Sample {\r\n  private static Sample s = null ;\r\n  public static Sample getSample() {\r\n    if (s == null) {\r\n      s = new Sample() ;\r\n    }\r\n  return s ;\r\n  }\r\n}\r\n<\/pre>\n<div style=\"text-align: center\"><strong>Listing 1<\/strong><\/div>\n<p>This code is not thread safe. If 2 threads t1 and t2 enter the getSample() method at the same time, they are likely to get different instances of sample. This can be fixed easily by adding the synchronized keyword to the getSample() method.<\/p>\n<pre class=\"brush:java\">public class Sample {\r\n  private static Sample s = null ;\r\n  public static synchronized Sample getSample() {\r\n    if (s == null) {\r\n      s = new Sample() ;\r\n    }\r\n    return s ;\r\n  }\r\n}\r\n<\/pre>\n<div style=\"text-align: center\"><strong>Listing 2<\/strong><\/div>\n<p>Now the getSample method works correctly. Before entering the getSample method, thread t1 accquires a lock. Any other thread t2 that needs to enter the method will block until t1 exits the method and releases the lock. Code works. Life is good. This is where the smart programmer if not careful, can outsmart himself. He will notice that in reality only the first call to getSample, which creates the instance, needs to be synchronized and subsequent calls that merely return s are paying an unnecessary penalty. He decides to optimize the code to<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:java\">public class Sample {\r\n  private static Sample s = null ;\r\n  public static Sample getSample() {\r\n    if (s == null) {\r\n      synchronized(Sample.class) {\r\n        s = new Sample() ;\r\n      }\r\n    }\r\n    return s ;\r\n  }\r\n}\r\n<\/pre>\n<div style=\"text-align: center\"><strong>Listing 3<\/strong><\/div>\n<p>Our java guru quickly realizes that this code has the same problem that listing 1 has. So he fine tunes it further.<\/p>\n<pre class=\"brush:java\">public class Sample {\r\n  private static Sample s = null ;\r\n  public static Sample getSample() {\r\n    if (s == null) {\r\n      synchronized(Sample.class) {\r\n        if (s == null) {\r\n          s = new Sample() ;\r\n        }\r\n      }\r\n    }\r\n    return s ;\r\n  }\r\n}\r\n<\/pre>\n<div style=\"text-align: center\"><strong>Listing 4<\/strong><\/div>\n<p>By adding an additional check withing the synchronized block, he has ensured that only one thread will ever create an instance of the sample. This is the double check pattern. Our guru&#8217;s friend, a java expert, buddy reviews the code. Code is checked in and product is shipped. Life is good right ?<\/p>\n<p><strong><i>Wrong<\/i><\/strong> !! Let us say thread t1 enters getSample. s is null. It gets a lock. Within the synchronized block, it checks that s is still null and then executes the constructor for Sample. Before the execution of the constructor completes t1 is swapped out and t2 gets control. Since the constructor did not complete, s is partially initialized. It is not null, but has some corrupt or incomplete value. When t2 enters getSample, it sees that s is not null and returns a corrupt value.<\/p>\n<p>In summary, the double check pattern does not work. The options are to synchronize at a method level as in listing 2 or to forego synchronization and use a static field as shown below.<\/p>\n<pre class=\"brush:java\">public class Sample {\r\n  private static Sample INSTANCE = new Sample();\r\n\r\n  public static Sample getSample()  {\r\n    return INSTANCE ;\r\n  }\r\n}\r\n<\/pre>\n<div style=\"text-align: center\"><strong>Listing 5<\/strong><\/div>\n<p>Better is the enemy of good!<\/p>\n<p>Byron<\/p>\n<p><strong>Related Articles:<\/strong><\/p>\n<ul style=\"text-align: left\">\n<li><a href=\"http:\/\/www.javacodegeeks.com\/?tag=java-best-practices\">Java Best Practices Series<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/01\/10-tips-proper-application-logging.html\">10 Tips for Proper Application Logging<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/12\/things-every-programmer-should-know.html\">Things Every Programmer Should Know<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/02\/9-tips-on-surviving-wild-west.html\">9 Tips on Surviving the Wild West Development Process<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/01\/laws-of-software-design.html\">Laws of Software Design<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/03\/design-patterns-in-jdk.html\">Design Patterns in the JDK<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The issue discussed in this article is not new, but still tricky even for seasoned developers.&nbsp;The singleton pattern is a common programming idiom. Nevertheless when used with multiple threads, some type of synchronization&nbsp;must be done in order not to break the code. In a relevant article our JCG partner Manoj Khangaonkar from The Khangaonkar Report&nbsp;examines &hellip;<\/p>\n","protected":false},"author":305,"featured_media":148,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[72,167],"class_list":["post-391","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-core-java","tag-multithreading","tag-singleton-pattern"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>The dreaded double checked locking idiom in Java - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"The issue discussed in this article is not new, but still tricky even for seasoned developers.&nbsp;The singleton pattern is a common programming idiom.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The dreaded double checked locking idiom in Java - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"The issue discussed in this article is not new, but still tricky even for seasoned developers.&nbsp;The singleton pattern is a common programming idiom.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2011-03-10T08:20:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-24T14:16:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Manoj Khangaonkar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Manoj Khangaonkar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/03\\\/dreaded-double-checked-locking-idiom-in.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/03\\\/dreaded-double-checked-locking-idiom-in.html\"},\"author\":{\"name\":\"Manoj Khangaonkar\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/1b867f5998ce2a4a4c514239c96637fd\"},\"headline\":\"The dreaded double checked locking idiom in Java\",\"datePublished\":\"2011-03-10T08:20:00+00:00\",\"dateModified\":\"2012-10-24T14:16:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/03\\\/dreaded-double-checked-locking-idiom-in.html\"},\"wordCount\":503,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/03\\\/dreaded-double-checked-locking-idiom-in.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/java-logo.jpg\",\"keywords\":[\"Multithreading\",\"Singleton Pattern\"],\"articleSection\":[\"Core Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/03\\\/dreaded-double-checked-locking-idiom-in.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/03\\\/dreaded-double-checked-locking-idiom-in.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/03\\\/dreaded-double-checked-locking-idiom-in.html\",\"name\":\"The dreaded double checked locking idiom in Java - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/03\\\/dreaded-double-checked-locking-idiom-in.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/03\\\/dreaded-double-checked-locking-idiom-in.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/java-logo.jpg\",\"datePublished\":\"2011-03-10T08:20:00+00:00\",\"dateModified\":\"2012-10-24T14:16:09+00:00\",\"description\":\"The issue discussed in this article is not new, but still tricky even for seasoned developers.&nbsp;The singleton pattern is a common programming idiom.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/03\\\/dreaded-double-checked-locking-idiom-in.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/03\\\/dreaded-double-checked-locking-idiom-in.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/03\\\/dreaded-double-checked-locking-idiom-in.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/java-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/java-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/03\\\/dreaded-double-checked-locking-idiom-in.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/core-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"The dreaded double checked locking idiom in Java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/1b867f5998ce2a4a4c514239c96637fd\",\"name\":\"Manoj Khangaonkar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/56f9c038909f5c71f8a524fc672805e758a44d1fdb2ef98e7eed9c806a468f24?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/56f9c038909f5c71f8a524fc672805e758a44d1fdb2ef98e7eed9c806a468f24?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/56f9c038909f5c71f8a524fc672805e758a44d1fdb2ef98e7eed9c806a468f24?s=96&d=mm&r=g\",\"caption\":\"Manoj Khangaonkar\"},\"sameAs\":[\"http:\\\/\\\/khangaonkar.blogspot.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Manoj-Khangaonkar\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The dreaded double checked locking idiom in Java - Java Code Geeks","description":"The issue discussed in this article is not new, but still tricky even for seasoned developers.&nbsp;The singleton pattern is a common programming idiom.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html","og_locale":"en_US","og_type":"article","og_title":"The dreaded double checked locking idiom in Java - Java Code Geeks","og_description":"The issue discussed in this article is not new, but still tricky even for seasoned developers.&nbsp;The singleton pattern is a common programming idiom.","og_url":"https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2011-03-10T08:20:00+00:00","article_modified_time":"2012-10-24T14:16:09+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","type":"image\/jpeg"}],"author":"Manoj Khangaonkar","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Manoj Khangaonkar","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html"},"author":{"name":"Manoj Khangaonkar","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/1b867f5998ce2a4a4c514239c96637fd"},"headline":"The dreaded double checked locking idiom in Java","datePublished":"2011-03-10T08:20:00+00:00","dateModified":"2012-10-24T14:16:09+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html"},"wordCount":503,"commentCount":1,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","keywords":["Multithreading","Singleton Pattern"],"articleSection":["Core Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html","url":"https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html","name":"The dreaded double checked locking idiom in Java - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","datePublished":"2011-03-10T08:20:00+00:00","dateModified":"2012-10-24T14:16:09+00:00","description":"The issue discussed in this article is not new, but still tricky even for seasoned developers.&nbsp;The singleton pattern is a common programming idiom.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2011\/03\/dreaded-double-checked-locking-idiom-in.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/core-java"},{"@type":"ListItem","position":4,"name":"The dreaded double checked locking idiom in Java"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/1b867f5998ce2a4a4c514239c96637fd","name":"Manoj Khangaonkar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/56f9c038909f5c71f8a524fc672805e758a44d1fdb2ef98e7eed9c806a468f24?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/56f9c038909f5c71f8a524fc672805e758a44d1fdb2ef98e7eed9c806a468f24?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/56f9c038909f5c71f8a524fc672805e758a44d1fdb2ef98e7eed9c806a468f24?s=96&d=mm&r=g","caption":"Manoj Khangaonkar"},"sameAs":["http:\/\/khangaonkar.blogspot.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Manoj-Khangaonkar"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/305"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=391"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/391\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/148"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}