Update Test924 to filter for messages related to test thread

Test924 tests that the thread messages are working as expected.
To test this, it constructs a thread, yields and sleeps and then
starts the thread. It expects that there are no events between the
construction of the thread and starting the thread. Though it is not
always guaranteed that there won't be activity corresponding to some
other thread. To prevent corner cases, filter out messages corresponding
to other threads.

Bug: 246688031
Change-Id: I36445d8df87c748b472b21b1a49e11b92907fea1
diff --git a/test/924-threads/src/art/Test924.java b/test/924-threads/src/art/Test924.java
index e97c9c6..3555720 100644
--- a/test/924-threads/src/art/Test924.java
+++ b/test/924-threads/src/art/Test924.java
@@ -337,6 +337,19 @@
     }
   }
 
+  private static List<String> filterForThread(Object[] thread_messages, String thread_name) {
+    List<String> messageListForThread = new ArrayList<String>();
+
+    for (int i = 0; i < thread_messages.length; i++) {
+      String message = (String)thread_messages[i];
+      if (message.startsWith("Thread(" + thread_name + ")")) {
+        messageListForThread.add(message);
+      }
+    }
+
+    return messageListForThread;
+  }
+
   private static void doTestEvents() throws Exception {
     enableThreadEvents(true);
 
@@ -354,21 +367,24 @@
         }
       }
     };
-    Thread t = new Thread(r, "EventTestThread");
+    String thread_name = "EventTestThread";
+    Thread t = new Thread(r, thread_name);
 
     System.out.println("Constructed thread");
     Thread.yield();
     Thread.sleep(100);
-    System.out.println(Arrays.toString(getThreadEventMessages()));
+
+    // Check that there are no events related to EventTestThread that we just created.
+    System.out.println(filterForThread(getThreadEventMessages(), thread_name).toString());
 
     t.start();
     cdl1.await();
 
-    System.out.println(Arrays.toString(getThreadEventMessages()));
+    System.out.println(filterForThread(getThreadEventMessages(), thread_name).toString());
 
     cdl2.countDown();
     t.join();
-    System.out.println(Arrays.toString(getThreadEventMessages()));
+    System.out.println(filterForThread(getThreadEventMessages(), thread_name).toString());
 
     System.out.println("Thread joined");