@@ -1629,59 +1629,19 @@ private void exit() {
1629
1629
}
1630
1630
1631
1631
/**
1632
- * Forces the thread to stop executing.
1633
- * <p>
1634
- * If there is a security manager installed, its {@code checkAccess}
1635
- * method is called with {@code this}
1636
- * as its argument. This may result in a
1637
- * {@code SecurityException} being raised (in the current thread).
1638
- * <p>
1639
- * If this thread is different from the current thread (that is, the current
1640
- * thread is trying to stop a thread other than itself), the
1641
- * security manager's {@code checkPermission} method (with a
1642
- * {@code RuntimePermission("stopThread")} argument) is called in
1643
- * addition.
1644
- * Again, this may result in throwing a
1645
- * {@code SecurityException} (in the current thread).
1646
- * <p>
1647
- * The thread represented by this thread is forced to stop whatever
1648
- * it is doing abnormally and to throw a newly created
1649
- * {@code ThreadDeath} object as an exception.
1650
- * <p>
1651
- * It is permitted to stop a thread that has not yet been started.
1652
- * If the thread is eventually started, it immediately terminates.
1653
- * <p>
1654
- * An application should not normally try to catch
1655
- * {@code ThreadDeath} unless it must do some extraordinary
1656
- * cleanup operation (note that the throwing of
1657
- * {@code ThreadDeath} causes {@code finally} clauses of
1658
- * {@code try} statements to be executed before the thread
1659
- * officially terminates). If a {@code catch} clause catches a
1660
- * {@code ThreadDeath} object, it is important to rethrow the
1661
- * object so that the thread actually terminates.
1662
- * <p>
1663
- * The top-level error handler that reacts to otherwise uncaught
1664
- * exceptions does not print out a message or otherwise notify the
1665
- * application if the uncaught exception is an instance of
1666
- * {@code ThreadDeath}.
1632
+ * Throws {@code UnsupportedOperationException}.
1667
1633
*
1668
- * @throws SecurityException if the current thread cannot
1669
- * modify this thread.
1670
- * @throws UnsupportedOperationException if invoked on a virtual thread
1671
- * @see #interrupt()
1672
- * @see #checkAccess()
1673
- * @see ThreadDeath
1674
- * @see ThreadGroup#uncaughtException(Thread,Throwable)
1675
- * @see SecurityManager#checkAccess(Thread)
1676
- * @see SecurityManager#checkPermission
1677
- * @deprecated This method is inherently unsafe. Stopping a thread with
1678
- * Thread.stop causes it to unlock all of the monitors that it
1679
- * has locked (as a natural consequence of the unchecked
1680
- * {@code ThreadDeath} exception propagating up the stack). If
1634
+ * @throws UnsupportedOperationException always
1635
+ *
1636
+ * @deprecated This method was originally specified to "stop" a victim
1637
+ * thread by causing the victim thread to throw a {@link ThreadDeath}.
1638
+ * It was inherently unsafe. Stopping a thread caused it to unlock
1639
+ * all of the monitors that it had locked (as a natural consequence
1640
+ * of the {@code ThreadDeath} exception propagating up the stack). If
1681
1641
* any of the objects previously protected by these monitors were in
1682
- * an inconsistent state, the damaged objects become visible to
1683
- * other threads, potentially resulting in arbitrary behavior. Many
1684
- * uses of {@code stop} should be replaced by code that simply
1642
+ * an inconsistent state, the damaged objects became visible to
1643
+ * other threads, potentially resulting in arbitrary behavior.
1644
+ * Usages of {@code stop} should be replaced by code that simply
1685
1645
* modifies some variable to indicate that the target thread should
1686
1646
* stop running. The target thread should check this variable
1687
1647
* regularly, and return from its run method in an orderly fashion
@@ -1695,26 +1655,7 @@ private void exit() {
1695
1655
*/
1696
1656
@ Deprecated (since ="1.2" , forRemoval =true )
1697
1657
public final void stop () {
1698
- @ SuppressWarnings ("removal" )
1699
- SecurityManager security = System .getSecurityManager ();
1700
- if (security != null ) {
1701
- checkAccess ();
1702
- if (this != Thread .currentThread ()) {
1703
- security .checkPermission (SecurityConstants .STOP_THREAD_PERMISSION );
1704
- }
1705
- }
1706
-
1707
- if (isVirtual ())
1708
- throw new UnsupportedOperationException ();
1709
-
1710
- // A zero status value corresponds to "NEW", it can't change to
1711
- // not-NEW because we hold the lock.
1712
- if (holder .threadStatus != 0 ) {
1713
- resume (); // Wake up thread if it was suspended; no-op otherwise
1714
- }
1715
-
1716
- // The VM can handle all thread states
1717
- stop0 (new ThreadDeath ());
1658
+ throw new UnsupportedOperationException ();
1718
1659
}
1719
1660
1720
1661
/**
@@ -3094,7 +3035,6 @@ static void setHeadStackableScope(StackableScope scope) {
3094
3035
3095
3036
/* Some private helper methods */
3096
3037
private native void setPriority0 (int newPriority );
3097
- private native void stop0 (Object o );
3098
3038
private native void suspend0 ();
3099
3039
private native void resume0 ();
3100
3040
private native void interrupt0 ();
0 commit comments