Index: modules/luni/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java =================================================================== --- modules/luni/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java (revision 475251) +++ modules/luni/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java (working copy) @@ -46,6 +46,7 @@ static class MockServer extends Thread { ServerSocket serverSocket; boolean accepted = false; + boolean started = false; public MockServer(String name) throws IOException { super(name); @@ -61,6 +62,7 @@ public void run() { try { synchronized (bound) { + started = true; bound.notify(); } try { @@ -195,11 +197,11 @@ server.start(); synchronized(bound) { - bound.wait(5000); + if (!server.started) bound.wait(5000); } proxy.start(); synchronized(bound) { - bound.wait(5000); + if (!proxy.started) bound.wait(5000); } connection.connect(); @@ -240,11 +242,11 @@ server.start(); synchronized(bound) { - bound.wait(5000); + if (!server.started) bound.wait(5000); } proxy.start(); synchronized(bound) { - bound.wait(5000); + if (!proxy.started) bound.wait(5000); } connection.connect();