2 Minutes To Code (β Version)

Apache Commons Http Client - 2 minute tutorial

Worker.java - Source code of artefact used in the examples of this tutorial

Given below is the source code for Worker.java that is used in the multi-threaded http-client examples above.
package com.techfundaes.httpBag;

import org.apache.commons.httpclient.methods.GetMethod;

public class WorkerThread extends Thread
{
	String url = "http://www.google.com";
	
	public void run()
	{
		GetMethod getMethod = new GetMethod(url);
		try
		{
			MultiThreadedHttp.httpClient.executeMethod(getMethod);
			System.out.println(this.getName() + " : " + getMethod.getResponseBodyAsString().substring(0, 25));
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			getMethod.releaseConnection();
		}
	}
}