Return-Path: Delivered-To: apmail-lucene-java-dev-archive@www.apache.org Received: (qmail 98224 invoked from network); 10 May 2006 07:02:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 10 May 2006 07:02:32 -0000 Received: (qmail 19301 invoked by uid 500); 10 May 2006 07:02:29 -0000 Delivered-To: apmail-lucene-java-dev-archive@lucene.apache.org Received: (qmail 19252 invoked by uid 500); 10 May 2006 07:02:28 -0000 Mailing-List: contact java-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-dev@lucene.apache.org Received: (qmail 19241 invoked by uid 99); 10 May 2006 07:02:28 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 May 2006 00:02:28 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [209.86.89.66] (HELO elasmtp-spurfowl.atl.sa.earthlink.net) (209.86.89.66) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 May 2006 00:02:27 -0700 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; d=ix.netcom.com; b=ae16XxGJ0Ct+Lq4fx7bT+FMWD/97FkbuPnQNcExb8UuvLYamBt0a4xYtw/ZZas31; h=Received:Reply-To:From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:X-Priority:X-MSMail-Priority:X-Mailer:In-Reply-To:Importance:X-MimeOLE:X-ELNK-Trace:X-Originating-IP; Received: from [66.245.135.50] (helo=ENGELSSERVER) by elasmtp-spurfowl.atl.sa.earthlink.net with asmtp (Exim 4.34) id 1Fdihy-0007EM-2f for java-dev@lucene.apache.org; Wed, 10 May 2006 03:02:06 -0400 Reply-To: From: "Robert Engels" To: Subject: RE: Multiple threads searching in Lucene and the synchronized issue. -- solution attached. Date: Wed, 10 May 2006 02:02:12 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-ELNK-Trace: 33cbdd8ed9881ca8776432462e451d7bd15d05d9470ff710ee6a112d62508502d8249e29a348af1e350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 66.245.135.50 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N For what its worth... That is not my understanding. My understanding is that volatile just ensures the JIT always accesses the var in order - prevents some compiler optimizations - where as synchronized needs to acquire the lock. (There were discussions regarding having volatile create synchronized accessors behind the scenes - but I don't think that semantic was ever agreed upon). That coupled with using primitives (to avoid the early memory alloc - since primitives are allocated on the stack), allows the double-locked synchronization to work (at least that is my understanding). -----Original Message----- From: Chris Hostetter [mailto:hossman_lucene@fucit.org] Sent: Wednesday, May 10, 2006 12:51 AM To: Lucene Dev Subject: RE: Multiple threads searching in Lucene and the synchronized issue. -- solution attached. : I think you could use a volatile primitive boolean to control whether or not : the index needs to be read, and also mark the index data volatile and it : SHOULD PROBABLY work. : : But as stated, I don't think the performance difference is worth it. My understanding is: 1) volatile will only help as of java 1.5 ... lucene targets 1.4 compatibility. 2) in 1.5, volatile is basically just as expensive as synchronized. : I met these problem before indeed.The compiler did something optimized for : me that was bad for me when I see the byte-codes. : When I'm using a function local variable, m_indexTerms and in JDK1.5.06, it : seems ok. : Whether it will break in other environments, I still don't know about it. The dangerous thing is that even if the byte code looks okay, and if it works okay today, your app could run for a while and then all of the sudden it could stop working because of the order the threads are run, or becuase of an optimization the JVM applies on the fly. -Hoss --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org For additional commands, e-mail: java-dev-help@lucene.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org For additional commands, e-mail: java-dev-help@lucene.apache.org