Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 4177 invoked from network); 19 Nov 2007 17:19:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Nov 2007 17:19:16 -0000 Received: (qmail 22693 invoked by uid 500); 19 Nov 2007 17:19:03 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 22669 invoked by uid 500); 19 Nov 2007 17:19:03 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 22660 invoked by uid 99); 19 Nov 2007 17:19:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Nov 2007 09:19:03 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Nov 2007 17:19:01 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7201F1A9832; Mon, 19 Nov 2007 09:18:55 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r596372 - in /harmony/enhanced/drlvm/trunk/vm/vmcore/src: kernel_classes/javasrc/java/lang/Thread.java thread/thread_java_basic.cpp Date: Mon, 19 Nov 2007 17:18:53 -0000 To: commits@harmony.apache.org From: wjwashburn@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071119171855.7201F1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: wjwashburn Date: Mon Nov 19 09:18:50 2007 New Revision: 596372 URL: http://svn.apache.org/viewvc?rev=596372&view=rev Log: Harmony-3267: this fixes several bugs with Thread.stop() Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_basic.cpp Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java?rev=596372&r1=596371&r2=596372&view=diff ============================================================================== --- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java (original) +++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java Mon Nov 19 09:18:50 2007 @@ -586,38 +586,28 @@ /** * @com.intel.drl.spec_ref */ - public final void join() throws InterruptedException { - synchronized (lock) { - while (isAlive()) { - // 2000msec timeout added to provide graceful degradation - // in case there is a race condition where lock.wait somehow - // misses the "detach() lock.notifyAll()" - // Or, more likely, does not see this.isAlive = false - // because this.isAlive is still stuck in a CPU's store buffer - // the only drawback is if there are 100's of threads doing join()'s - // and the overhead of the continual timeouts may be a problem - // Let's first see a big money workload that waits on 100's of threads - // simultaneously before we worry - lock.wait(2000); - } + public final synchronized void join() throws InterruptedException { + notifyAll(); + while (isAlive()) { + wait(); } } /** * @com.intel.drl.spec_ref */ - public final void join(long millis) throws InterruptedException { + public final synchronized void join(long millis) throws InterruptedException { if (millis == 0) { join(); - return; - } - - synchronized (lock) { + } else { + notifyAll(); long end = System.currentTimeMillis() + millis; while(isAlive()) { - lock.wait(millis); + wait(millis); millis = end - System.currentTimeMillis(); - if (millis <= 0) return; + if (millis <= 0) { + break; + } } } } @@ -625,23 +615,21 @@ /** * @com.intel.drl.spec_ref */ - public final void join(long millis, int nanos) + public final synchronized void join(long millis, int nanos) throws InterruptedException { - if (millis < 0 || nanos < 0 || nanos > 999999) + if (millis < 0 || nanos < 0 || nanos > 999999) { throw new IllegalArgumentException(); - - if (millis == 0 && nanos == 0) { + } else if (millis == 0 && nanos == 0) { join(); - return; - } - - synchronized (lock) { + } else { + notifyAll(); long end = System.nanoTime() + 1000000*millis + (long)nanos; long rest; while (isAlive()) { - lock.wait(millis, nanos); + wait(millis, nanos); rest = end - System.nanoTime(); - if (rest <= 0) return; + if (rest <= 0) + break; nanos = (int)(rest % 1000000); millis = rest / 1000000; } @@ -792,9 +780,9 @@ } } finally { group.remove(this); - synchronized(lock) { - this.isAlive = false; - lock.notifyAll(); + synchronized(this) { + isAlive = false; + notifyAll(); } } } Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_basic.cpp URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_basic.cpp?rev=596372&r1=596371&r2=596372&view=diff ============================================================================== --- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_basic.cpp (original) +++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_basic.cpp Mon Nov 19 09:18:50 2007 @@ -469,22 +469,6 @@ // Does not return if the exception could be thrown straight away jthread_throw_exception_object(excn); - - // getting here means top stack frame is non-unwindable. - if (hythread_get_state(native_thread) & - (TM_THREAD_STATE_SLEEPING | TM_THREAD_STATE_WAITING_WITH_TIMEOUT - | TM_THREAD_STATE_WAITING | TM_THREAD_STATE_IN_MONITOR_WAIT - | TM_THREAD_STATE_WAITING_INDEFINITELY | TM_THREAD_STATE_PARKED)) - { - // This is needed for correct stopping of a thread blocked on monitor_wait. - // The thread needs some flag to exit its waiting loop. - // We piggy-back on interrupted status. A correct exception from TLS - // will be thrown because the check of exception status on leaving - // JNI frame comes before checking return status in Object.wait(). - // Interrupted status will be cleared by function returning TM_ERROR_INTERRUPT. - // (though, in case of parked thread, it will not be cleared) - hythread_interrupt(native_thread); - } } // stop_callback /**