Fix for AMQ-1340 - Thread gets stuck in a WAIT and never returns

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@559092 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2007-07-24 16:19:43 +00:00
parent 8f6fac7f1b
commit 5a3a45f0c0
2 changed files with 7 additions and 3 deletions

View File

@ -146,7 +146,7 @@ public class TransportConnector implements Connector {
public void onAccept(final Transport transport) { public void onAccept(final Transport transport) {
try { try {
// Starting the connection could block due to // Starting the connection could block due to
// wireformat negociation, so start it in an async thread. // wireformat negotiation, so start it in an async thread.
Thread startThread = new Thread("ActiveMQ Transport Initiator: "+transport.getRemoteAddress()) { Thread startThread = new Thread("ActiveMQ Transport Initiator: "+transport.getRemoteAddress()) {
public void run() { public void run() {
try { try {

View File

@ -67,8 +67,9 @@ class DedicatedTaskRunner implements TaskRunner {
pending=true; pending=true;
mutex.notifyAll(); mutex.notifyAll();
// Wait till the thread stops. // Wait till the thread stops ( no need to wait if shutdown
if(!threadTerminated){ // is called from thread that is shutting down)
if( Thread.currentThread()!=thread && !threadTerminated ){
mutex.wait(timeout); mutex.wait(timeout);
} }
} }
@ -97,6 +98,9 @@ class DedicatedTaskRunner implements TaskRunner {
if( !task.iterate() ) { if( !task.iterate() ) {
// wait to be notified. // wait to be notified.
synchronized (mutex) { synchronized (mutex) {
if( shutdown ) {
return;
}
while( !pending ) { while( !pending ) {
mutex.wait(); mutex.wait();
} }