summaryrefslogtreecommitdiffstats
path: root/libart/src
diff options
context:
space:
mode:
Diffstat (limited to 'libart/src')
-rw-r--r--libart/src/main/java/java/lang/Thread.java14
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;
}