Return-Path: X-Original-To: apmail-river-dev-archive@www.apache.org Delivered-To: apmail-river-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7C0FDFCEC for ; Sat, 27 Apr 2013 10:51:20 +0000 (UTC) Received: (qmail 19367 invoked by uid 500); 27 Apr 2013 10:51:20 -0000 Delivered-To: apmail-river-dev-archive@river.apache.org Received: (qmail 19165 invoked by uid 500); 27 Apr 2013 10:51:16 -0000 Mailing-List: contact dev-help@river.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@river.apache.org Delivered-To: mailing list dev@river.apache.org Received: (qmail 19126 invoked by uid 99); 27 Apr 2013 10:51:14 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Apr 2013 10:51:14 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [207.57.65.70] (HELO zeus.net.au) (207.57.65.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Apr 2013 10:51:07 +0000 Received: (qmail 26623 invoked by uid 16710); 27 Apr 2013 10:50:44 -0000 Received: from unknown (HELO [10.1.1.15]) (jini@[61.9.223.241]) (envelope-sender ) by 207.57.65.70 (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 27 Apr 2013 10:50:44 -0000 Message-ID: <517BADAE.3080001@zeus.net.au> Date: Sat, 27 Apr 2013 20:51:26 +1000 From: Peter Firmstone User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20 MIME-Version: 1.0 To: dev@river.apache.org Subject: Re: ThreadPool calling Thread.setName References: <517A4D70.5040703@zeus.net.au> <1366980282.8176.63.camel@cameron> <517A9B3E.6040408@acm.org> In-Reply-To: <517A9B3E.6040408@acm.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Ok found the link, the paper's called: Position paper: Nondeterminism is unavoidable, but data races are pure evil http://www.hpl.hp.com/techreports/2012/HPL-2012-218.pdf Wheather Thread's name field is an issue or not depends on the code that uses it (Object.toString() and Thread.getName() methods do) and what that code does with the information. Outrigger uses it in lifecycle logs, although it doesn't appear to be called on any threads from ThreadPool. Instead Outrigger calls getName() on threads it references from fields in OutriggerServerImpl. These fields have since been changed to final, so if the name is set during construction and not changed after publication, it's thread safe, in addition these threads aren't started until after OutriggerServerImpl's constructor returns. The concurrency issues I most recently experienced were related to Outrigger, I couldn't determine the cause of these failures, perhaps I lack sufficient ability to reason deeply about these issues, my fix for the problem was akin to carpet bombing; fix every concurrency problem and that appears to have paid off. It's very difficult to determine if toString() may be called on ThreadPool threads. I reasoned it could be and that was sufficient justification to not use setName(). Cheers, Peter. On 27/04/2013 1:20 AM, Patricia Shanahan wrote: > I've looked at the source code. The field "name" that is shared > between threads doing getName or setName on a given Thread is a > reference. Writes and reads of references are always atomic. > > The worst that could happen is that the change to the name does not > propagate to all threads that might display information about the > thread. The proposed fix ensures that worst case outcome happens all > the time. > > Patricia > > On 4/26/2013 5:44 AM, Greg Trasuk wrote: >> >> I'm curious, as I don't see any indication in the Javadocs that >> setName() isn't thread safe. Is there another reference that calls that >> out? And what would be the failure mode, apart from a mangled string in >> a log output? >> >> Personally, if the potential failure mode wasn't onerous, I'd opt for >> more descriptive logging. Comprehensibility is everything when you're >> troubleshooting. >> >> Cheers, >> >> Greg. >> >> On Fri, 2013-04-26 at 05:48, Peter Firmstone wrote: >>> Hope you don't mind, I've removed the call to Thread.setName in >>> com.sun.jini.ThreadPool >>> >>> As a result threads will be less descriptive, unfortunately setName >>> isn't thread safe, it's final and cannot be overridden. Thread.getName >>> is only thread safe if a Thread's name isn't changed after publication. >>> >>> ThreadPool was the only instance of Thread.setName in River. >>> >>> Regards, >>> >>> Peter. >> >