diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java
index 7ac69e9..d4cac1f 100644
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java
+++ b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java
@@ -472,87 +472,6 @@
 	}
 
 	/**
-	 * @tests java.lang.ThreadGroup#resume()
-	 */
-	@SuppressWarnings("deprecation")
-    public void test_resume() throws OutOfMemoryError {
-		// Test for method void java.lang.ThreadGroup.resume()
-
-		final ThreadGroup originalCurrent = getInitialThreadGroup();
-
-		final ThreadGroup testRoot = new ThreadGroup(originalCurrent,
-				"Test group");
-		final int DEPTH = 2;
-		buildRandomTreeUnder(testRoot, DEPTH);
-
-		final int THREADS_PER_GROUP = 2;
-		final Vector<MyThread> threads = populateGroupsWithThreads(testRoot,
-				THREADS_PER_GROUP);
-
-		boolean[] isResumed = null;
-		try {
-			try {
-				for (int i = 0; i < threads.size(); i++) {
-					Thread t = threads.elementAt(i);
-					t.start();
-					t.suspend();
-				}
-				// In 5.0, activeCount() only returns threads that are alive
-				assertTrue("Internal error when populating ThreadGroups", testRoot
-						.activeCount() == threads.size());
-			} catch (OutOfMemoryError e) {
-				for (int i = 0; i < threads.size(); i++) {
-					Thread t = threads.elementAt(i);
-					t.resume();
-					t.stop(); // deprecated but effective
-				}
-				throw e;
-			}
-
-			// Now that they are all suspended, let's resume the ThreadGroup
-			testRoot.resume();
-
-			// Give them some time to really resume
-			try {
-				Thread.sleep(500);
-			} catch (InterruptedException ie) {
-				fail("Should not have been interrupted");
-			}
-
-			isResumed = new boolean[threads.size()];
-			boolean failed = false;
-			for (int i = 0; i < isResumed.length; i++) {
-				MyThread t = threads.elementAt(i);
-				if (!failed) { // if one failed, don't waste time checking the
-					// rest
-					isResumed[i] = t.isActivelyRunning(1000);
-					failed = failed | (!isResumed[i]);
-				}
-				t.stop(); // deprecated but effective
-			}
-
-			// Give them some time to really die
-			try {
-				Thread.sleep(500);
-			} catch (InterruptedException ie) {
-				fail("Should not have been interrupted");
-			}
-		} finally {
-			// Make sure we do cleanup before returning
-			testRoot.destroy();
-		}
-
-		for (int i = 0; i < isResumed.length; i++) {
-			assertTrue("Thread " + threads.elementAt(i)
-					+ " was not running when it was killed", isResumed[i]);
-		}
-
-		assertEquals("Method destroy must have problems",
-				0, testRoot.activeCount());
-
-	}
-
-	/**
 	 * @tests java.lang.ThreadGroup#setDaemon(boolean)
 	 */
 	public void test_setDaemonZ() {
@@ -681,177 +600,6 @@
 	}
 
 	/**
-	 * @tests java.lang.ThreadGroup#stop()
-	 */
-	@SuppressWarnings("deprecation")
-    public void test_stop() throws OutOfMemoryError {
-		// Test for method void java.lang.ThreadGroup.stop()
-
-		final ThreadGroup originalCurrent = getInitialThreadGroup();
-
-		final ThreadGroup testRoot = new ThreadGroup(originalCurrent,
-				"Test group");
-		final int DEPTH = 2;
-		buildRandomTreeUnder(testRoot, DEPTH);
-
-		final int THREADS_PER_GROUP = 2;
-		final Vector<MyThread> threads = populateGroupsWithThreads(testRoot,
-				THREADS_PER_GROUP);
-
-		try {
-			for (int i = 0; i < threads.size(); i++) {
-				Thread t = threads.elementAt(i);
-				t.start();
-			}
-		} catch (OutOfMemoryError e) {
-			for (int i = 0; i < threads.size(); i++) {
-				Thread t = threads.elementAt(i);
-				t.stop(); // deprecated but effective
-			}
-			throw e;
-		}
-
-		// Now that they are all running, let's stop the ThreadGroup
-		testRoot.stop();
-
-		// stop is an async call. The thread may take a while to stop. We have
-		// to wait for all of them to stop. However, if stop does not work,
-		// we'd have to wait forever. So, we wait with a timeout, and if the
-		// Thread is still alive, we assume stop for ThreadGroups does not
-		// work. How much we wait (timeout) is very important
-		boolean passed = true;
-		for (int i = 0; i < threads.size(); i++) {
-			Thread t = threads.elementAt(i);
-			try {
-				// We wait 5000 ms per Thread, but due to scheduling it may
-				// take a while to run
-				t.join(5000);
-			} catch (InterruptedException ie) {
-				fail("Should not be interrupted");
-			}
-			if (t.isAlive()) {
-				passed = false;
-				break;
-			}
-		}
-
-		// To make sure that even if we fail, we exit in a clean state
-		testRoot.destroy();
-
-		assertTrue("Thread should be dead by now", passed);
-
-		assertEquals("Method destroy (or wipeAllThreads) must have problems",
-				0, testRoot.activeCount());
-
-	}
-
-	/**
-	 * @tests java.lang.ThreadGroup#suspend()
-	 */
-	@SuppressWarnings("deprecation")
-    public void test_suspend() throws OutOfMemoryError {
-		// Test for method void java.lang.ThreadGroup.suspend()
-
-		final ThreadGroup originalCurrent = getInitialThreadGroup();
-
-		final ThreadGroup testRoot = new ThreadGroup(originalCurrent,
-				"Test group");
-		final int DEPTH = 2;
-		buildRandomTreeUnder(testRoot, DEPTH);
-
-		final int THREADS_PER_GROUP = 2;
-		final Vector<MyThread> threads = populateGroupsWithThreads(testRoot,
-				THREADS_PER_GROUP);
-
-		boolean passed = false;
-		try {
-			try {
-				for (int i = 0; i < threads.size(); i++) {
-					Thread t = threads.elementAt(i);
-					t.start();
-				}
-			} catch (OutOfMemoryError e) {
-				for (int i = 0; i < threads.size(); i++) {
-					Thread t = threads.elementAt(i);
-					t.stop(); // deprecated but effective
-				}
-				throw e;
-			}
-
-			// Now that they are all running, let's suspend the ThreadGroup
-			testRoot.suspend();
-
-			passed = allSuspended(threads);
-			assertTrue("Should be able to wipe all threads (allSuspended="
-					+ passed + ")", wipeAllThreads(testRoot));
-		} finally {
-
-			// We can't destroy a ThreadGroup if we do not make sure it has no
-			// threads at all
-            testRoot.stop();
-            long waitTime = 5000;
-            for (int i = 0; i < threads.size(); i++) {
-                Thread t = threads.elementAt(i);
-                while (t.isAlive() && waitTime >= 0) {
-                   try {
-                      Thread.sleep(10);
-                      waitTime -= 10;
-                   } catch (InterruptedException e) {
-                      fail("unexpected interruption");
-                   }
-                }
-                if (waitTime < 0) {
-                   fail("stop() has not stopped threads in ThreadGroup 'testRoot'");
-                }
-             }
-			// Make sure we cleanup before returning from the method
-			testRoot.destroy();
-		}
-		assertTrue("All threads should be suspended", passed);
-
-		assertEquals("Method destroy (or wipeAllThreads) must have problems",
-				0, testRoot.activeCount());
-
-	}
-
-	/**
-	 * @tests java.lang.ThreadGroup#toString()
-	 */
-	public void test_toString() {
-		// Test for method java.lang.String java.lang.ThreadGroup.toString()
-
-		final ThreadGroup originalCurrent = getInitialThreadGroup();
-		final String tGroupName = "Test group";
-
-		// Our own subclass
-		class MyThreadGroup extends ThreadGroup {
-			// Have to define a constructor since there's no default one
-			public MyThreadGroup(ThreadGroup parent, String name) {
-				super(parent, name);
-			}
-		}
-		;
-
-		ThreadGroup testRoot = new MyThreadGroup(originalCurrent, tGroupName);
-		final String toString = testRoot.toString();
-
-		StringBuffer expectedResult = new StringBuffer();
-		expectedResult.append(testRoot.getClass().getName());
-		expectedResult.append("[name=");
-		expectedResult.append(tGroupName);
-		expectedResult.append(",maxpri=");
-		expectedResult.append(testRoot.getMaxPriority());
-		expectedResult.append("]");
-
-		String expectedValue = expectedResult.toString();
-
-		assertTrue("toString does not follow the Java language spec.", toString
-				.equals(expectedValue));
-
-		testRoot.destroy();
-	}
-
-	/**
 	 * @tests java.lang.ThreadGroup#uncaughtException(java.lang.Thread,
 	 *        java.lang.Throwable)
 	 */
@@ -897,43 +645,6 @@
 			}
 		};
 
-		// Test if a Thread tells its ThreadGroup about ThreadDeath
-		thread = new Thread(testRoot, null, "victim thread (to be killed)") {
-			@Override
-            public void run() {
-				while (true) {
-					Thread.yield();
-				}
-			}
-		};
-		thread.start();
-		try {
-			Thread.sleep(1000);
-		} catch (InterruptedException ie) {
-			fail("Should not have been interrupted");
-		}
-		// we know this is deprecated, but we must test this scenario.
-		// When we stop a thread, it is tagged as not alive even though it is
-		// still running code.
-		// join would be a no-op, and we might have a race condition. So, to
-		// play safe, we wait before joining & testing if the exception was
-		// really forwarded to the ThreadGroup
-		thread.stop();
-		try {
-			Thread.sleep(1000);
-		} catch (InterruptedException ie) {
-			fail("Should not have been interrupted");
-		}
-		try {
-			thread.join();
-		} catch (InterruptedException ie) {
-			fail("Should not have been interrupted");
-		}
-		testRoot.destroy();
-		assertTrue(
-				"Any thread should notify its ThreadGroup about its own death, even if killed:"
-						+ testRoot, passed[TEST_KILLING]);
-
 		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 		// - - - - - - -
 		testRoot = new ThreadGroup(originalCurrent,
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadTest.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadTest.java
index ba35ada..4816975 100644
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadTest.java
+++ b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadTest.java
@@ -742,38 +742,6 @@
 	}
 
 	/**
-	 * @tests java.lang.Thread#resume()
-	 */
-	@SuppressWarnings("deprecation")
-    public void test_resume() {
-		// Test for method void java.lang.Thread.resume()
-		int orgval;
-		ResSupThread t;
-		try {
-			t = new ResSupThread(Thread.currentThread());
-			synchronized (t) {
-				ct = new Thread(t, "Interrupt Test2");
-				ct.start();
-				t.wait();
-			}
-			ct.suspend();
-			// Wait to be sure the suspend has occurred
-			Thread.sleep(500);
-			orgval = t.getCheckVal();
-			// Wait to be sure the thread is suspended
-			Thread.sleep(500);
-			assertTrue("Failed to suspend thread", orgval == t.getCheckVal());
-			ct.resume();
-			// Wait to be sure the resume has occurred.
-			Thread.sleep(500);
-			assertTrue("Failed to resume thread", orgval != t.getCheckVal());
-			ct.interrupt();
-		} catch (InterruptedException e) {
-			fail("Unexpected interrupt occurred : " + e.getMessage());
-		}
-	}
-
-	/**
 	 * @tests java.lang.Thread#run()
 	 */
 	public void test_run() {
@@ -906,115 +874,6 @@
 	}
 
 	/**
-	 * @tests java.lang.Thread#stop()
-	 */
-	@SuppressWarnings("deprecation")
-    public void test_stop() {
-		// Test for method void java.lang.Thread.stop()
-		try {
-			Runnable r = new ResSupThread(null);
-			synchronized (r) {
-				st = new Thread(r, "Interupt Test5");
-				st.start();
-				r.wait();
-			}
-
-		} catch (InterruptedException e) {
-			fail("Unexpected interrupt received");
-		}
-		st.stop();
-
-		try {
-			st.join(10000);
-		} catch (InterruptedException e1) {
-			st.interrupt();
-			fail("Failed to stopThread before 10000 timeout");
-		}
-		assertTrue("Failed to stopThread", !st.isAlive());
-	}
-
-	/**
-	 * @tests java.lang.Thread#stop(java.lang.Throwable)
-	 */
-	@SuppressWarnings("deprecation")
-    public void test_stopLjava_lang_Throwable() {
-		// Test for method void java.lang.Thread.stop(java.lang.Throwable)
-		ResSupThread t = new ResSupThread(Thread.currentThread());
-		synchronized (t) {
-			st = new Thread(t, "StopThread");
-			st.setPriority(Thread.MAX_PRIORITY);
-			st.start();
-			try {
-				t.wait();
-			} catch (InterruptedException e) {
-			}
-		}
-		try {
-			st.stop(new BogusException("Bogus"));
-			Thread.sleep(20000);
-		} catch (InterruptedException e) {
-			assertTrue("Stopped child with exception not alive", st.isAlive());
-			st.interrupt();
-			return;
-		}
-		st.interrupt();
-		fail("Stopped child did not throw exception");
-	}
-
-	/**
-	 * @tests java.lang.Thread#suspend()
-	 */
-	@SuppressWarnings("deprecation")
-    public void test_suspend() {
-		// Test for method void java.lang.Thread.suspend()
-		int orgval;
-		ResSupThread t = new ResSupThread(Thread.currentThread());
-		try {
-			synchronized (t) {
-				ct = new Thread(t, "Interupt Test6");
-				ct.start();
-				t.wait();
-			}
-			ct.suspend();
-			// Wait to be sure the suspend has occurred
-			Thread.sleep(500);
-			orgval = t.getCheckVal();
-			// Wait to be sure the thread is suspended
-			Thread.sleep(500);
-			assertTrue("Failed to suspend thread", orgval == t.getCheckVal());
-			ct.resume();
-			// Wait to be sure the resume has occurred.
-			Thread.sleep(500);
-			assertTrue("Failed to resume thread", orgval != t.getCheckVal());
-			ct.interrupt();
-		} catch (InterruptedException e) {
-			fail("Unexpected interrupt occurred");
-		}
-
-		final Object notify = new Object();
-		Thread t1 = new Thread(new Runnable() {
-			public void run() {
-				synchronized (notify) {
-					notify.notify();
-				}
-				Thread.currentThread().suspend();
-			}
-		});
-		try {
-			synchronized (notify) {
-				t1.start();
-				notify.wait();
-			}
-			// wait for Thread to suspend
-			Thread.sleep(500);
-			assertTrue("Thread should be alive", t1.isAlive());
-			t1.resume();
-			t1.join();
-		} catch (InterruptedException e) {
-		}
-	}
-
-	/**
 	 * @tests java.lang.Thread#toString()
 	 */
 	public void test_toString() {
