Throttling CPU/Memory usage of a Thread in Java?

前端 未结 9 2286
借酒劲吻你
借酒劲吻你 2020-12-07 13:00

I\'m writing an application that will have multiple threads running, and want to throttle the CPU/memory usage of those threads.

There is a similar question for C++,

9条回答
  •  余生分开走
    2020-12-07 13:13

    The only way you can limit Thread CPU usage is by either block on a resource or to call yield() frequently.

    This does not limit CPU usage below 100% but gives other threads and processes more timeslices.

提交回复
热议问题