[英]How to manage M threads (1 per task) ensuring only N threads at the same time. With N < M. In Java
[英]Running same test in parrallel in N threads M times
我有一个带有单元测试的 spring 应用程序。 我想检查我的代码在 N 个线程中运行时的工作方式。 现在我在测试中使用java.util.concurrent.Executor
、 ExecutableFuture
、 spring 批处理功能等。
有没有简单的方法,像这样的注释:
@SuperPuperParallelTest(threadCount=5, timesToRun=100)
@Test
public void myTestMethod() { ... }
还是另一种(最好是注释驱动)方法?
看看tempus-fugit 。 它是一个 Java 库,可以帮助我们使用方便的注释测试并发代码。
例如,请参见此处: https://www.baeldung.com/java-testing-multithreaded
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.