문제

I'm using httpcomponents 4.3.3 to do posts. I would like to name the threads it uses so I can easily see them in a thread dump. Is it possible? I see there's a way to wrap an HttpClient in a FutureRequestExecutionService, and give that a ThreadFactory that will provided named threads. Is there another option? I'm currently creating my HttpClient like so:

httpClient = HttpClients.custom().setRetryHandler(requestRetryHandler).build();
도움이 되었습니까?

해결책

java.lang.Thread has a setName() method. If the thread you want to name extends Thread, you can call setName("myThread") on it.

EDIT: Based on this suggestion, Alper Akture was able to figure out an actual solution.

ExecutorService has a constructor that accepts a ThreadFactory, and the ThreadFactory can be told to create named threads.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top