I have a few threads running, which are all required to constantly take pictures of different areas of screen. Each thread has its own instance of Robot
. The problem is, rather than the shots being taken asynchronously by each thread, they seem to be taken one at a time.
E.g, if I take only one screenshot, it only takes about 20-30 milliseconds. But if I have 5 threads and they all try to take screenshots (of different parts of the screen), then it seems to take 100 - 150 milliseconds to get all 5 screenshots, clearly showing that the shots are being taken synchronously despite the robot.createScreenCapture()
method being called from different threads. I want all 5 screenshots to be taken in 20-30 milliseconds.
Is there a way to make robot work asynchronously and send the screenshots to each thread simultaneously? Or a different method of taking screenshots asynchronously which will work in Windows?