how to detect window process with high CPU or memory usage
when detected the process is high CPU or memory usage, then restart it.
For example, when the "chrome.exe" is high CPU or memory usage and detected:
Then restart the chrome
Runtime.getRuntime().exec("taskkill /im chrome.exe /f");
Runtime.getRuntime().exec("start chrome");