如何在java多线程中找到等待时间与服务时间之比
我试图根据我的系统配置,计算出可以为特定应用程序创建的最大线程数
我用了一个公式:
N_threads = N_cpu * U_cpu * (1 + W / C)
where,
N_threads is the optimal number of threads
N_cpu is the number of prcessors
U_cpu is the target CPU utilization
W / C is the ratio of wait time to compute time (0 for CPU-bound task, maybe 10 or 100 for slow I/O tasks)
基于为I/o绑定任务计算的W/c
有人能帮我解决这个问题吗
# 1 楼答案
W/C
表示等待时间与计算时间之间的比率,它属于范围[0; 100]
例如,当您选择10作为
W/C
的值时,这意味着等待时间应该比计算时间大10倍。通常,值越高,等待时间越长我没有确切的方法来确定这个比率。但我想和你们分享我的启发性建议。我会问自己:“我应该等待其他主持人的回答的可能性有多大?”