在测试单元中,也就是一个测试方法,新建一个线程然后使用logback打印简单的输出语句正常,但是使用占位符会出现程序上的正常停止。,但是在main方法内没有任何问题
package test;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import java.util.concurrent.locks.LockSupport;
import static java.lang.Thread.sleep;
@Slf4j(topic = "Test1.class")
public class Test1 {
@Test
public void test1() {
log.info("start test1");
Thread t1 = new Thread(() -> {
log.info("parking");
log.info("unpark");
log.info("------------");
log.info("inturper status {}", "[hei]");
log.info("------------");
log.info("dadadadada");
}, "t1");
t1.start();
}
public static void main(String[] args) throws InterruptedException {
log.info("start test1");
Thread t1 = new Thread(() -> {
log.info("parking");
log.info("unpark");
log.info("------------");
log.info("inturper status {}", "[hei]");
log.info("------------");
log.info("dadadadada");
}, "t1");
t1.start();
}
}
在test1方法的运行结果:
mian方法内的运行结果:
你可以看看这个https://blog.csdn.net/forthefuture_/article/details/108346216
单元测试好像测试多线程好像就是有点问题。
你的main方法里面也是启动线程呀
这跟线程压根就没有关系
再说了,这就是一排减号,哪里有占位符
你的test1哪里有调用了
把你异常的代码发出来看,不要发不出问题的代码