< prev index next >
src/java.desktop/share/classes/java/awt/Robot.java
Print this page
@@ -640,24 +640,24 @@
delay(autoDelay);
}
/**
* Sleeps for the specified time.
- * To catch any {@code InterruptedException}s that occur,
- * {@code Thread.sleep()} may be used instead.
+ * <p>
+ * If the invoking thread is interrupted while waiting, then its interrupt
+ * status will be set and this method returns immediately.
*
* @param ms time to sleep in milliseconds
- * @throws IllegalArgumentException if {@code ms}
- * is not between 0 and 60,000 milliseconds inclusive
- * @see java.lang.Thread#sleep
+ * @throws IllegalArgumentException if {@code ms} is not between {@code 0}
+ * and {@code 60,000} milliseconds inclusive
*/
- public synchronized void delay(int ms) {
+ public void delay(int ms) {
checkDelayArgument(ms);
try {
Thread.sleep(ms);
- } catch(InterruptedException ite) {
- ite.printStackTrace();
+ } catch(final InterruptedException ignored) {
+ Thread.currentThread().interrupt(); // Preserve interrupt status
}
}
private void checkDelayArgument(int ms) {
if (ms < 0 || ms > MAX_DELAY) {
< prev index next >