how to cpu scavenging in Java?
My program is a distributed software for a small laboratory. It is written in java but because during daytime the computers are used, I have to manually restart it in the evening. I would solve the problem by starting it from a s开发者_如何学编程ervice every time the computer is started but I need a mechanism to detect: 1) user input(mouse, keyboard etc.) 2) user logon
Detecting any user input from java it is not possible. Is there any framework for something like this?
Detecting user input from Java is possible, but not with standard tecnologies. Considering the excellent example of aTunes, you can do it using, depending upon your platform
- JIntelliType on Windows
- JXGrabKey on Linux
Considering your other question, I would use native abilities of client OSes to better handle your problem. First thing is to make your Java process lower priority. This way, it will run all time long, without having the user blocked by it. I would also force this program to stop when CPU load is over a given target. This can be achieved using JMX, as this previous question explains.
精彩评论