diff --git a/test/hotspot/jtreg/containers/docker/ShareTmpDir.java b/test/hotspot/jtreg/containers/docker/ShareTmpDir.java index b7f807d76a3..bbf08c0dae7 100644 --- a/test/hotspot/jtreg/containers/docker/ShareTmpDir.java +++ b/test/hotspot/jtreg/containers/docker/ShareTmpDir.java @@ -66,17 +66,23 @@ public class ShareTmpDir { private static void test() throws Exception { File sharedtmpdir = new File("sharedtmpdir"); File flag = new File(sharedtmpdir, "flag"); - File started = new File(sharedtmpdir, "started"); + File started1 = new File(sharedtmpdir, "started-1"); + File started2 = new File(sharedtmpdir, "started-2"); sharedtmpdir.mkdir(); flag.delete(); - started.delete(); + started1.delete(); + started2.delete(); DockerRunOptions opts = new DockerRunOptions(imageName, "/jdk/bin/java", "WaitForFlagFile"); + Object lock = new Object(); opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/"); opts.addDockerOpts("--volume", sharedtmpdir.getAbsolutePath() + ":/tmp/"); opts.addJavaOpts("-Xlog:os+container=trace", "-Xlog:perf+memops=debug", "-cp", "/test-classes/"); Thread t1 = new Thread() { public void run() { + synchronized(lock) { + opts.addClassOptions("1"); + } try { out1 = Common.run(opts); } catch (Exception e) { e.printStackTrace(); } } }; @@ -84,13 +90,16 @@ public class ShareTmpDir { Thread t2 = new Thread() { public void run() { + synchronized(lock) { + opts.addClassOptions("2"); + } try { out2 = Common.run(opts); } catch (Exception e) { e.printStackTrace(); } } }; t2.start(); - while (!started.exists()) { - System.out.println("Wait for at least one JVM to start"); + while (!started1.exists() || !started2.exists()) { + System.out.println("Waiting for all two JVMs to start"); Thread.sleep(1000); } diff --git a/test/hotspot/jtreg/containers/docker/WaitForFlagFile.java b/test/hotspot/jtreg/containers/docker/WaitForFlagFile.java index 64596830a3f..ed549e33cf1 100644 --- a/test/hotspot/jtreg/containers/docker/WaitForFlagFile.java +++ b/test/hotspot/jtreg/containers/docker/WaitForFlagFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ public class WaitForFlagFile { public static void main(String[] args) throws Exception { System.out.println("WaitForFlagFile: Entering"); - File started = new File("/tmp/started"); + File started = new File("/tmp/started-" + args.length); FileOutputStream fout = new FileOutputStream(started); fout.close();