Hopefully de-flake 165-lock-owner-proxy

Wait for system daemons to start up before really running the test.

Failures are too infrequent to really test this. Hope for the best.

Test: Treehugger
Bug: 260228356
Change-Id: I9c6ffef29130eb4577a0f95b8d8e213ffa8db832
diff --git a/test/165-lock-owner-proxy/src/Main.java b/test/165-lock-owner-proxy/src/Main.java
index fff8e58..99a6d42 100644
--- a/test/165-lock-owner-proxy/src/Main.java
+++ b/test/165-lock-owner-proxy/src/Main.java
@@ -18,6 +18,11 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 
+// Note that this is run with a tiny heap.
+// See b/260228356 for some discussion. It's unclear if and how this reliably forces an
+// OOME. For now, we're keeping this around because it appears to have detected some bugs
+// in the past. It may need revisiting.
+
 public class Main {
     static final int numberOfThreads = 5;
     static final int totalOperations = 10000;
@@ -27,9 +32,16 @@
     static volatile boolean finish = false;
 
     public static void main(String[] args) throws Exception {
+        // Wait for system daemons to start, so that we minimize the chances of
+        // a system daemon still starting up if/when we run out of memory.
+        try {
+            Thread.sleep(100);
+        } catch (InterruptedException e) {
+            System.out.println("Unexpected interrupt:" + e);
+        }
+
         inf = (SimpleInterface)Proxy.newProxyInstance(SimpleInterface.class.getClassLoader(),
             new Class[] { SimpleInterface.class }, new EmptyInvocationHandler());
-
         Thread garbageThread = new Thread(new GarbageRunner());
         garbageThread.start();
 
@@ -111,6 +123,7 @@
                 try {
                     Thread.sleep(10);
                 } catch (Exception e) {
+                    System.out.println("Unexpected exception in sleep():" + e);
                 }
             }
         }