hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Retter" <Adam.Ret...@landmarkinfo.co.uk>
Subject Httpclient 3.2 Threading problem
Date Fri, 25 Jul 2008 09:05:11 GMT
Hi Chaps,

I have a problem with HttpClient 3.2 and threading, either I am misusing
it or there is something awry.

My design is much like this (simplified) -

public abstract class absExternalSource {
	private final static private final static
MultiThreadedHttpConnectionManager connectionManager = new

	public HttpClient newClient()
		HttpClient client = new HttpClient(connectionManager);
		//do some config - i.e. proxy, user/agent etc etc

		return client;

I then have a number of classes that extend this abstract class, each
uses a http source to get some data, parses it and returns some sort of
data. I am very carefull to always call method.releaseConnection() in a
finally block for each method I execute.

Now from my main class I create a thread group, and start a thread for
each ExternalSource. I then wait for all of the threads to complete by
checking the ThreadGroups activeCount - e.g.

ThreadGroup tgExtSources = new ThreadGroup();
for(absExternalSource src : externalSources)
	new ExternalSourceThread(src, tgExtSources).start();

While(tgExtSources.activeCount > 0)

//all data collected from external sources

Now the problem is that the activeCount never reaches 0. All of my
external sources run their code and call method.releaseConnection() in
the finally block - but there is always a thread lingering which keeps
the tgExtSources.activeCount == 1. This thread is

Unfortunately that stops my application from ever completing, what is
this thread and whats it doing if anything? Considering that I have
released all the connections I would of thought it would complete?!?


Adam Retter

Landmark Information Group Ltd
5-7 Abbey Court
Eagle Way
Sowton Industrial Estate

t: +44(0)1392 685403
w: http://www.landmarkinfo.co.uk

Registered Office: 7 Abbey Court, Eagle Way, Sowton, Exeter, Devon, EX2 7HY
Registered Number 2892803 Registered in England and Wales 

This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

The information contained in this e-mail is confidential and may be subject to 
legal privilege. If you are not the intended recipient, you must not use, copy, 
distribute or disclose the e-mail or any part of its contents or take any 
action in reliance on it. If you have received this e-mail in error, please 
e-mail the sender by replying to this message. All reasonable precautions have 
been taken to ensure no viruses are present in this e-mail. Landmark Information
Group Limited cannot accept responsibility for loss or damage arising from the 
use of this e-mail or attachments and recommend that you subject these to 
your virus checking procedures prior to use.

To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

View raw message