Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 914969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:48:29+00:00 2026-05-15T17:48:29+00:00

I have a program whose only purpose is to drive a java.awt.Robot in an

  • 0

I have a program whose only purpose is to drive a java.awt.Robot in an infinite loop until an exit condition is met.

The robot performs a number of actions in quick succession, which require a standard UI delay between them. For this, I use java.awt.Robot.setAutoDelay(int ms), which appears to be designed for precisely this purpose.

At other times, however, I need to insert arbitrarily long delays for operations to complete. I appear to have a choice between using java.awt.Robot.delay(int ms) or java.lang.Thread.sleep(long ms), and am curious what the differences between them are, and which I should use.

My gut instinct was to keep all my operations in the same “place”, and use java.awt.Robot.delay(int ms). However, after thinking about it for a moment, I assumed that java.awt.Robot.delay(int ms) would put an operation on the Robot’s stack of operations to complete, and if those were my only delays in an infinite loop, I may very quickly, and needlessly, generate an absurdly large queue of events for the Robot.

At that point, I checked the API for java.awt.Robot.delay(int ms), which told me the following:

Sleeps for the specified time. To catch any InterruptedExceptions that occur, Thread.sleep() may be used instead.

Having failed to gain any useful insight into the matter, I elected to ask you guys.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:48:29+00:00Added an answer on May 15, 2026 at 5:48 pm

    At first I would also assume that using delay() would generate a large queue of events, in particular after reading the javadoc for waitForIdle():

    Waits until all events currently on the event queue have been processed

    but checking the source code of Robot.delay() shows that it basically is a Thread.sleep(), after checking that the delay time is positive and not more than 1 minute!

    Abstract: both solutions are almost the same, use Thread.sleep() for delaying longer than 1 minute or catching the InterruptedException.

    after years of programming with Java I found how to sleep without having to catch the InterruptedException (disregarding the overhead of creating a Robot)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 501k
  • Answers 501k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer http://www.appfoundation.com/blogs/giametta/2009/04/14/render-pdf-in-adobe-air-with-pdf-scaling/ http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=1375018 http://coenraets.org/blog/2009/11/open-in-excel-another-air-2-mini-sample/ also new docs are zip files, so… May 16, 2026 at 2:23 pm
  • Editorial Team
    Editorial Team added an answer Re how it works: the Wikipedia article discusses several techniques… May 16, 2026 at 2:23 pm
  • Editorial Team
    Editorial Team added an answer Regex.Split is more capable, but for an arrangement with basic… May 16, 2026 at 2:23 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a function that returns me only the fridays from a range of
I am writing an object oriented program whose business process calls for a ticket
I have an out-of-of-the-box software tool that I developed in Java. This software requires
I have a program that needs to retrieve some data about a set of
Not a terribly good question, sorry. I have a program that needs to be
I am working with a basic C++ program to determine the area and perimeter
I'm writing a python3 program, that gets the names of files to process from
I'm working on an GUI program, and I use AppendText to update status in
I am currently developing a library and a set of programs using this library,
In almost every project, I can't decide on how to deal with certain global

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.