Question

In the Robot documentation I don't see anything about Robot extending Thread. However, I am sure I have heard people say that the Robot runs in its own thread.

So, does each instance of Robot run in its own thread, do all robot instances run in one thread, or do they all simply run in the current thread?

Was it helpful?

Solution

The Robot class runs in the current thread. There's nothing in the source that starts a Thread. You can verify it easily enough too, just run this in Eclipse and look at the threads in Debug view:

List<Robot> robots = new ArrayList<Robot>();
for (int i = 0; i < 10; i++) {
    robots.add(new Robot());
}
Thread.sleep(60000);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top