码迷,mamicode.com
首页 > 编程语言 > 详细

Java程序控制CPU使用率

时间:2014-11-25 16:26:10      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:java thread cpu

参考: http://stackoverflow.com/questions/1202184/throttling-cpu-memory-usage-of-a-thread-in-java

one way would be to adaptively sleep the threads, similarly as video playback is done in Java. If you know you want 50% core utilization, the your algorithm should sleep approximately 0.5 seconds - potentially distributed within a second (e.g. 0.25 sec computation, 0.25 sec sleep, e.t.c.).

另外,从jvisualvm里面看到的cpu使用率,是机器上面的总的cpu使用率,如果pc机是4核的话,50%的CPU,显示的是12.5%, 100%的CPU,显示的是25%。

Java程序控制CPU使用率

标签:java thread cpu

原文地址:http://blog.csdn.net/nomad2/article/details/41483403

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!