JavaErlang线程池
使用Erlang,如何实现java线程池
与JavaAPI一样,ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)
我可以定义核心线程,终止线程的时间,并定义策略以放弃/拒绝任务
我使用这个池向其他服务发送http请求。如果远程服务器关闭,Java系统仍将保持稳定
我尝试了ErlangGen_server
和用户gen_server:cast
来处理请求
与gen_server
it will control the process and make the system stable.
问题是
1. how to kill the process if it take too long?
2. how define policy to discard/reject request?
3. is that possible to limit the total process?
# 1 楼答案
我建议您查看Github上为
erlang
标记的worker-pool
{a1}。我觉得worker_pool
可能适合你。它有一个(见溢出)和三个(见大小)需求