有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

如何在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) 个答案

  1. # 1 楼答案

    W/C表示等待时间计算时间之间的比率,它属于范围[0; 100]

    例如,当您选择10作为W/C的值时,这意味着等待时间应该比计算时间大10倍。通常,值越高,等待时间越长

    我没有确切的方法来确定这个比率。但我想和你们分享我的启发性建议。我会问自己:“我应该等待其他主持人的回答的可能性有多大?”

    • 大部分时间:
    • 有时:
    • 没有等待时间,那当然是0