Tom Storm wrote:I would like to try and limit the usage of both RAM and CPU in Java. I have created a very CPU intensive program and would like to limit its usage of the computers CPU time. The program is designed to be extremely inefficient as I would like to find a way to limit Java cou usage. Is it possible to do this in Java or even through a JNI? I understand that memory is already limited with Xmx.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Tom Storm wrote:I would like to try and limit the usage of both RAM and CPU in Java.
Tom Storm wrote:Do you mean to create a thread scheduler and then assign different priorities to threads?
Tom Storm wrote:
Possibly a method which analyses a certain number of objects, then sleeps for a certain period of time and then analyse the same number of objects in a continuous loop. I am not sure if that would result in smooth lower usages or extremely varied usages.
Thoughts?
Alexey Bezrodnov wrote:
No, I mean to create a method call in your worker thread. When thread performs some work in a loop, it calls a method to checks some flag value every iteration. If flag value is negative, then method calls wait(numberOfMilliseconds); If flag value is positive the method just returns. And flag value is managed by another thread, where you can define any logic you want the scheduler to implement.
Tom Storm wrote:If so my only objection is that the usage wouldn't change unless another thread of a higher priority needs cpu time. What I thought could be implemented was a method that would effectively slow down a Java program which would result in far less usage.
Tom Storm wrote:I would like to try and limit the usage of both RAM and CPU in Java. I have created a very CPU intensive program and would like to limit its usage of the computers CPU time. The program is designed to be extremely inefficient as I would like to find a way to limit Java cou usage. Is it possible to do this in Java or even through a JNI? I understand that memory is already limited with Xmx.
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|