Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A69F917E84 for ; Wed, 25 Feb 2015 21:08:06 +0000 (UTC) Received: (qmail 92291 invoked by uid 500); 25 Feb 2015 21:08:06 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 92190 invoked by uid 500); 25 Feb 2015 21:08:06 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 92176 invoked by uid 99); 25 Feb 2015 21:08:06 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Feb 2015 21:08:06 +0000 Date: Wed, 25 Feb 2015 21:08:06 +0000 (UTC) From: "Arthur Naseef (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (LANG-1086) Remove busy wait from AtomicSafeInitializer.get() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LANG-1086?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14337203#comment-14337203 ] Arthur Naseef commented on LANG-1086: ------------------------------------- Reading the javadocs for the atomic package, compareAndSet is the atomic operation. There is a lock there, whether it is in java code, machine instructions or other. Even if it's not called a lock. If no instructions can pass a point in the code until some event, that's a lock. Avoiding unstructured locks (i.e. unclear orders-of-operations with lock and unlock steps) and large critical sections is very valuable in concurrent implementations. Implementing a concurrency toolset without locks - at some level - isn't possible. Ultimately, there must be some form of atomic "check-and-set" which means a lock; it could be a spinlock (busy-wait with a mostly-guaranteed very short "spin" life), but it still operates as a lock. In spite of any of this, the existing busy-wait solution is problematic. Especially if the initialize method throws an exception, leaving other threads busy-waiting indefinitely. Oh, and does the LazyInitiaizer get a "pass" on the rules? It's calling the initializer inside a "synchronized' block. > Remove busy wait from AtomicSafeInitializer.get() > ------------------------------------------------- > > Key: LANG-1086 > URL: https://issues.apache.org/jira/browse/LANG-1086 > Project: Commons Lang > Issue Type: Improvement > Components: lang.concurrent.* > Reporter: Benedikt Ritter > Assignee: Benedikt Ritter > Labels: github > Fix For: 3.4 > > > Placeholder ticket for https://github.com/apache/commons-lang/pull/46 > {quote} > Remove the busy wait from AtomicSafeInitializer.get(). > Also ensure waiting threads do not wait indefinitely after initialize() throws an exception, instead throwing the same exception, re-wrapped, for each requester. > Brought the unit tests up to 100% coverage on AtomicSafeInitializer. Eliminated race condition on verifying at least one thread waiting for initialize() to complete in another thread. > {quote} -- This message was sent by Atlassian JIRA (v6.3.4#6332)