15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test id=default
26 * @summary Do not suspend virtual threads in a critical section.
27 * @bug 8311218
28 * @requires vm.continuations
29 * @library /testlibrary
30 * @run main/othervm SuspendWithInterruptLock
31 */
32
33 /**
34 * @test id=xint
35 * @summary Do not suspend virtual threads in a critical section.
36 * @bug 8311218
37 * @requires vm.continuations
38 * @library /testlibrary
39 * @run main/othervm -Xint SuspendWithInterruptLock
40 */
41
42 import jvmti.JVMTIUtils;
43
44 public class SuspendWithInterruptLock {
45 static volatile boolean done;
46
47 public static void main(String[] args) throws Exception {
48 Thread yielder = Thread.ofVirtual().name("yielder").start(() -> yielder());
49 Thread stateReader = Thread.ofVirtual().name("stateReader").start(() -> stateReader(yielder));
50 Thread suspender = new Thread(() -> suspender(stateReader));
51 suspender.start();
52
53 yielder.join();
54 stateReader.join();
55 suspender.join();
56 }
57
58 static private void yielder() {
59 int iterations = 100_000;
60 while (iterations-- > 0) {
61 Thread.yield();
|
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test id=default
26 * @summary Do not suspend virtual threads in a critical section.
27 * @bug 8311218
28 * @requires vm.continuations
29 * @library /testlibrary
30 * @run main/othervm SuspendWithInterruptLock
31 */
32
33 /**
34 * @test id=xint
35 * @requires vm.debug != true
36 * @requires vm.continuations
37 * @library /testlibrary
38 * @run main/othervm -Xint SuspendWithInterruptLock
39 */
40
41 /**
42 * @test id=xint-debug
43 * @requires vm.debug == true
44 * @requires vm.continuations
45 * @library /testlibrary
46 * @run main/othervm -Xint -XX:-VerifyContinuations SuspendWithInterruptLock
47 */
48
49 import jvmti.JVMTIUtils;
50
51 public class SuspendWithInterruptLock {
52 static volatile boolean done;
53
54 public static void main(String[] args) throws Exception {
55 Thread yielder = Thread.ofVirtual().name("yielder").start(() -> yielder());
56 Thread stateReader = Thread.ofVirtual().name("stateReader").start(() -> stateReader(yielder));
57 Thread suspender = new Thread(() -> suspender(stateReader));
58 suspender.start();
59
60 yielder.join();
61 stateReader.join();
62 suspender.join();
63 }
64
65 static private void yielder() {
66 int iterations = 100_000;
67 while (iterations-- > 0) {
68 Thread.yield();
|