---
title: "HttpClient 4 必须设超时时间，否则线程一直等在那."
author: "kong6001"
date: "2014-06-08T11:20:02Z"
tags: []
categories: ["编程语言"]
slug: "httpclient-4"
draft: false
lastmod: "2014-06-08T11:20:02Z"
id: 2077173
url: "https://fanchi.iteye.com/blog/2077173"
---

// Note: must set timeout,otherwise alway wait here.

        // set time out

        // conntction timeout 20s

        httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION\_TIMEOUT, 20000);

        // transfer time 60s

        httpclient.getParams().setParameter(CoreConnectionPNames.SO\_TIMEOUT, 60000);