Name: joT67522 Date: 11/26/97
Compile ThreadTest.java and run with
parameters such as:
java -mx500k -ms500k ThreadTest
It will eventually die with an OutOfMemoryError.
If you remove the call to "thread.stop()"
from the code, it will run happily for quite
a long time. Each call to stop() seems to
leak memory until the JVM finally dies.
This failure occurs with both with java
1.1.3 (as supplied with Solaris 2.6) and
with JDK 1.1.4 with the native threads pack.
Using native or green threads does not seem
to matter. Using the JIT or not does not
make a difference either.
The program always dies.
This is a serious
problem for server programming --- we're building
a service for a major customer using the Java
Web Server and we need the ability to create
threads on the fly and kill them after a
specified timeout.
------------------------
public class ThreadTest
{
public static void main(String[] args)
{
while (true) {
Thread thread = new Thread() {
public void run()
{
try {
sleep(10);
} catch (InterruptedException e) {
}
}
};
thread.start();
thread.stop();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
}
}
}
}
------------------------
(Review ID: 20933)
======================================================================
- duplicates
-
JDK-4098405 (thread) Thread target instance variable should be nulled when thread is stopped
-
- Closed
-