Implement the Thread.sleep native method.

This makes returning TS_SLEEPING from JDWP simple and cheap, and
makes the stack dumps for sleeping threads more easily understood
by app developers (because there's no Object.wait magic going, and
the thread state is "Sleeping" rather than "TimedWaiting").

Also make Object.wait() a native method in its own right, so every call into
Monitor::Wait can explicitly pass the most appropriate ThreadState: kSleeping,
kWaiting, or kTimedWaiting.

Also add Thread.sleep and Object.wait(long, int) calls to the ThreadStress test.

Change-Id: I49adb45dbcd669eba7cf3def45e6cbfc461a3254
diff --git a/test/ThreadStress/ThreadStress.java b/test/ThreadStress/ThreadStress.java
index 5389c20..8d8135d 100644
--- a/test/ThreadStress/ThreadStress.java
+++ b/test/ThreadStress/ThreadStress.java
@@ -34,7 +34,10 @@
         ALLOC(60),
         STACKTRACE(20),
         EXIT(50),
-        WAIT(50);
+
+        SLEEP(25),
+        TIMED_WAIT(10),
+        WAIT(15);
 
         private final int frequency;
         Operation(int frequency) {
@@ -48,7 +51,7 @@
         final int totalOperations = 1000;
         final int operationsPerThread = totalOperations/numberOfThreads;
 
-        // Lock used to notify threads performin Operation.WAIT
+        // Lock used to notify threads performing Operation.WAIT
         final Object lock = new Object();
 
         // Each thread is going to do operationsPerThread
@@ -203,11 +206,26 @@
                         } catch (ErrnoException ex) {
                         }
                     }
+                    case SLEEP: {
+                        try {
+                            Thread.sleep(100);
+                        } catch (InterruptedException ignored) {
+                        }
+                    }
+                    case TIMED_WAIT: {
+                        synchronized (lock) {
+                            try {
+                                lock.wait(100, 0);
+                            } catch (InterruptedException ignored) {
+                            }
+                        }
+                        break;
+                    }
                     case WAIT: {
                         synchronized (lock) {
                             try {
                                 lock.wait();
-                            } catch (InterruptedException e) {
+                            } catch (InterruptedException ignored) {
                             }
                         }
                         break;