summaryrefslogtreecommitdiffstats
path: root/test/050-sync-test/src
diff options
context:
space:
mode:
authorAlex Light <allight@google.com>2014-07-22 14:04:31 -0700
committerAlex Light <allight@google.com>2014-07-22 14:39:08 -0700
commit8d9044bb4039bfd46b20edce4cff929906e492c6 (patch)
treec92f00e820a733e3d56bef207a171545da6c0a6e /test/050-sync-test/src
parent16fc9f617e395758eb95b5f2124c79a828186b55 (diff)
downloadart-8d9044bb4039bfd46b20edce4cff929906e492c6.zip
art-8d9044bb4039bfd46b20edce4cff929906e492c6.tar.gz
art-8d9044bb4039bfd46b20edce4cff929906e492c6.tar.bz2
Made sync-test actually wait for first thread to start.
This makes sure that the threads execute in the order we expect. Change-Id: I0c4976e72ef2eb9e5fd66184eb1cd4821ea1e42b
Diffstat (limited to 'test/050-sync-test/src')
-rw-r--r--test/050-sync-test/src/Main.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/test/050-sync-test/src/Main.java b/test/050-sync-test/src/Main.java
index ec6d732..5364e2a 100644
--- a/test/050-sync-test/src/Main.java
+++ b/test/050-sync-test/src/Main.java
@@ -50,13 +50,14 @@ public class Main {
one = new CpuThread(1);
two = new CpuThread(2);
- one.start();
-
- try {
- Thread.sleep(100);
- } catch (InterruptedException ie) {
- System.out.println("INTERRUPT!");
- ie.printStackTrace();
+ synchronized (one) {
+ one.start();
+ try {
+ one.wait();
+ } catch (InterruptedException ie) {
+ System.out.println("INTERRUPT!");
+ ie.printStackTrace();
+ }
}
two.start();
@@ -101,6 +102,9 @@ class CpuThread extends Thread {
//System.out.println(Thread.currentThread().getName());
synchronized (mSyncable) {
+ synchronized (this) {
+ this.notify();
+ }
for (int i = 0; i < 10; i++) {
output(mNumber);
}