shut down http connections with 5s timeout

This commit is contained in:
woodser 2024-01-26 09:07:03 -05:00
parent 64aa052d83
commit 8600c0cb0d
6 changed files with 85 additions and 69 deletions

View file

@ -35,7 +35,12 @@ public class ThreadUtils {
private static final int POOL_SIZE = 10;
private static final ExecutorService POOL = Executors.newFixedThreadPool(POOL_SIZE);
/**
* Execute the given command in a thread with the given id.
*
* @param command the command to execute
* @param threadId the thread id
*/
public static void execute(Runnable command, String threadId) {
synchronized (EXECUTORS) {
if (!EXECUTORS.containsKey(threadId)) EXECUTORS.put(threadId, Executors.newFixedThreadPool(1));
@ -107,6 +112,8 @@ public class ThreadUtils {
}
}
// TODO: consolidate and cleanup apis
public static Future<?> submitToPool(Runnable task) {
return submitToPool(Arrays.asList(task)).get(0);
}