diff options
author | Brian Carlstrom <bdc@google.com> | 2014-02-10 15:06:53 -0800 |
---|---|---|
committer | Brian Carlstrom <bdc@google.com> | 2014-02-10 15:59:05 -0800 |
commit | b5a43a8ad530a60469bf9244a157079c93c07c8b (patch) | |
tree | b114a5dfc69d6db3d413c37a3f9f17ba55dc2cca /libart/src | |
parent | 506021c4348ca13bc9a2734b9880c12576286c4f (diff) | |
download | libcore-b5a43a8ad530a60469bf9244a157079c93c07c8b.zip libcore-b5a43a8ad530a60469bf9244a157079c93c07c8b.tar.gz libcore-b5a43a8ad530a60469bf9244a157079c93c07c8b.tar.bz2 |
Fix Thread.sleep(0) of an interrupted thread
Bug: 12929305
Change-Id: I3061c3345c68de8bcf438e6935446b4f7cd76001
Diffstat (limited to 'libart/src')
-rw-r--r-- | libart/src/main/java/java/lang/Thread.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libart/src/main/java/java/lang/Thread.java b/libart/src/main/java/java/lang/Thread.java index 2cc2857..b826e66 100644 --- a/libart/src/main/java/java/lang/Thread.java +++ b/libart/src/main/java/java/lang/Thread.java @@ -993,9 +993,23 @@ public class Thread implements Runnable { * @see Thread#interrupt() */ public static void sleep(long millis, int nanos) throws InterruptedException { + if (millis < 0) { + throw new IllegalArgumentException("millis < 0: " + millis); + } + if (nanos < 0) { + throw new IllegalArgumentException("nanos < 0: " + nanos); + } + if (nanos > 999999) { + throw new IllegalArgumentException("nanos > 999999: " + nanos); + } + // The JLS 3rd edition, section 17.9 says: "...sleep for zero // time...need not have observable effects." if (millis == 0 && nanos == 0) { + // ...but we still have to handle being interrupted. + if (Thread.interrupted()) { + throw new InterruptedException(); + } return; } |