src/share/classes/java/lang/Thread.java

Print this page

        

*** 252,267 **** /** * The maximum priority that a thread can have. */ public final static int MAX_PRIORITY = 10; - /* If stop was called before start */ - private boolean stopBeforeStart; - - /* Remembered Throwable from stop before start */ - private Throwable throwableFromStop; - /** * Returns a reference to the currently executing thread object. * * @return the currently executing thread. */ --- 252,261 ----
*** 704,718 **** } catch (Throwable ignore) { /* do nothing. If start0 threw a Throwable then it will be passed up the call stack */ } } - - if (stopBeforeStart) { - stop0(throwableFromStop); } - } private native void start0(); /** * If this thread was constructed using a separate --- 698,708 ----
*** 818,834 **** * <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">Why * are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>. */ @Deprecated public final void stop() { ! // If the thread is already dead, return. ! // A zero status value corresponds to "NEW". ! if ((threadStatus != 0) && !isAlive()) { ! return; } - stop1(new ThreadDeath()); - } /** * Forces the thread to stop executing. * <p> * If there is a security manager installed, the <code>checkAccess</code> --- 808,819 ---- * <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">Why * are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>. */ @Deprecated public final void stop() { ! stop(new ThreadDeath()); } /** * Forces the thread to stop executing. * <p> * If there is a security manager installed, the <code>checkAccess</code>
*** 877,917 **** * <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">Why * are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>. */ @Deprecated public final synchronized void stop(Throwable obj) { - stop1(obj); - } - - /** - * Common impl for stop() and stop(Throwable). - */ - private final synchronized void stop1(Throwable th) { SecurityManager security = System.getSecurityManager(); if (security != null) { checkAccess(); if ((this != Thread.currentThread()) || ! (!(th instanceof ThreadDeath))) { security.checkPermission(SecurityConstants.STOP_THREAD_PERMISSION); } } ! // A zero status value corresponds to "NEW" if (threadStatus != 0) { resume(); // Wake up thread if it was suspended; no-op otherwise - stop0(th); - } else { - - // Must do the null arg check that the VM would do with stop0 - if (th == null) { - throw new NullPointerException(); } ! // Remember this stop attempt for if/when start is used ! stopBeforeStart = true; ! throwableFromStop = th; } - } /** * Interrupts this thread. * * <p> Unless the current thread is interrupting itself, which is --- 862,888 ---- * <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">Why * are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>. */ @Deprecated public final synchronized void stop(Throwable obj) { SecurityManager security = System.getSecurityManager(); if (security != null) { checkAccess(); if ((this != Thread.currentThread()) || ! (!(obj instanceof ThreadDeath))) { security.checkPermission(SecurityConstants.STOP_THREAD_PERMISSION); } } ! // A zero status value corresponds to "NEW", it can't change to ! // not-NEW because we hold the lock. if (threadStatus != 0) { resume(); // Wake up thread if it was suspended; no-op otherwise } ! // The VM can handle all thread states ! stop0(obj); } /** * Interrupts this thread. * * <p> Unless the current thread is interrupting itself, which is