< prev index next >
src/java.desktop/share/classes/java/awt/Robot.java
Print this page
*** 640,663 ****
delay(autoDelay);
}
/**
* Sleeps for the specified time.
! * To catch any {@code InterruptedException}s that occur,
! * {@code Thread.sleep()} may be used instead.
*
* @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
*/
! public synchronized void delay(int ms) {
checkDelayArgument(ms);
try {
Thread.sleep(ms);
! } catch(InterruptedException ite) {
! ite.printStackTrace();
}
}
private void checkDelayArgument(int ms) {
if (ms < 0 || ms > MAX_DELAY) {
--- 640,663 ----
delay(autoDelay);
}
/**
* Sleeps for the specified time.
! * <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 {@code 0}
! * and {@code 60,000} milliseconds inclusive
*/
! public void delay(int ms) {
checkDelayArgument(ms);
try {
Thread.sleep(ms);
! } catch(final InterruptedException ignored) {
! Thread.currentThread().interrupt(); // Preserve interrupt status
}
}
private void checkDelayArgument(int ms) {
if (ms < 0 || ms > MAX_DELAY) {
< prev index next >