HTTPCLIENT-625 for 4.0

git-svn-id: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpclient/trunk@506063 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Roland Weber 2007-02-11 16:26:38 +00:00
parent 9ce698c4d5
commit 12d50dda30

View File

@ -117,7 +117,7 @@ public class ThreadSafeClientConnManager
private ClientConnectionOperator connectionOperator; private ClientConnectionOperator connectionOperator;
/** Indicates whether this connection manager is shut down. */ /** Indicates whether this connection manager is shut down. */
private boolean isShutDown; private volatile boolean isShutDown;
@ -1011,7 +1011,7 @@ private static class WaitingThread {
*/ */
private static class ReferenceQueueThread extends Thread { private static class ReferenceQueueThread extends Thread {
private boolean isShutDown = false; private volatile boolean isShutDown = false;
/** /**
* Create an instance and make this a daemon thread. * Create an instance and make this a daemon thread.
@ -1023,6 +1023,7 @@ public ReferenceQueueThread() {
public void shutdown() { public void shutdown() {
this.isShutDown = true; this.isShutDown = true;
this.interrupt();
} }
/** /**
@ -1056,10 +1057,8 @@ private void handleReference(Reference ref) {
public void run() { public void run() {
while (!isShutDown) { while (!isShutDown) {
try { try {
// remove the next reference and process it, a timeout // remove the next reference and process it
// is used so that the thread does not block indefinitely Reference ref = REFERENCE_QUEUE.remove();
// and therefore keep the thread from shutting down
Reference ref = REFERENCE_QUEUE.remove(1000);
if (ref != null) { if (ref != null) {
handleReference(ref); handleReference(ref);
} }