diff --git a/test/jdk/com/sun/jdi/TwoThreadsTest.java b/test/jdk/com/sun/jdi/TwoThreadsTest.java index e38783f3ea6..e5732ffd8d1 100644 --- a/test/jdk/com/sun/jdi/TwoThreadsTest.java +++ b/test/jdk/com/sun/jdi/TwoThreadsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -55,6 +55,13 @@ public static void main(String[] args) { t1.start(); t2.start(); + // The threads might be virtual and daemon, so wait until completion. + try { + t1.join(); + t2.join(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } }