Increase the timeout for the test 2390

Flag: TEST_ONLY
Bug: 346542404
Test: 2390-virtual-thread-carrier-leak
Change-Id: I1d1d27ac497c83014d5115b0072464deae429f75
diff --git a/test/2390-virtual-thread-carrier-leak/src/Main.java b/test/2390-virtual-thread-carrier-leak/src/Main.java
index 54bf60d..01f46cb 100644
--- a/test/2390-virtual-thread-carrier-leak/src/Main.java
+++ b/test/2390-virtual-thread-carrier-leak/src/Main.java
@@ -27,6 +27,8 @@
 
     private static WeakReference<Thread> WEAK_REF = null;
 
+    private static final long NANOS_PER_SECOND = 1_000_000_000L;
+
     public static void main(String[] args) throws InterruptedException {
         if (!com.android.art.flags.Flags.virtualThreadImplV1()) {
             return;
@@ -41,10 +43,10 @@
         // Verify that a carrier thread isn't reachable and leaked by the underlying
         // Virtual Thread implementation after parking the Virtual Thread.
         VirtualThreadContext context = startVirtualThreadAndGetParkedContext();
-        long startTime = System.currentTimeMillis();
+        long startTime = System.nanoTime();
         while (!WEAK_REF.refersTo(null)) {
-            if (System.currentTimeMillis() - startTime > 10 * 1000) {
-                throw new AssertionError("10s time out");
+            if (System.nanoTime() - startTime > 20 * NANOS_PER_SECOND) {
+                throw new AssertionError("20s time out");
             }
             System.gc();
         }
diff --git a/test/2390-virtual-thread-context-leak/src/Main.java b/test/2390-virtual-thread-context-leak/src/Main.java
index 6f24fd2..7a372a53 100644
--- a/test/2390-virtual-thread-context-leak/src/Main.java
+++ b/test/2390-virtual-thread-context-leak/src/Main.java
@@ -35,6 +35,7 @@
  *  The spec may change in the future.
  */
 public class Main {
+    private static final long NANOS_PER_SECOND = 1_000_000_000L;
 
     public static void main(String[] args) throws InterruptedException {
         if (!com.android.art.flags.Flags.virtualThreadImplV1()) {
@@ -48,10 +49,10 @@
         });
 
         WeakReference<VirtualThreadContext> ref = startVirtualThreadAndGetParkedContext();
-        long startTime = System.currentTimeMillis();
+        long startTime = System.nanoTime();
         while (!ref.refersTo(null)) {
-            if (System.currentTimeMillis() - startTime > 10 * 1000) {
-                throw new AssertionError("10s time out");
+            if (System.nanoTime() - startTime > 20 * NANOS_PER_SECOND) {
+                throw new AssertionError("20s time out");
             }
             System.gc();
         }