public class Tbuser {
@ApiModelProperty(value="手机号")
private String mobile;
@ApiModelProperty(value="密码")
private String password;
private String salt;
@ApiModelProperty(value="1验证码登陆 2密码")
private String flag;
public static int iCount = 100;
public static void main(String[] args) {
Thread thread1 = new Thread(() -> {
while (true) {
iCount--;
if (iCount <= 0) break;
System.out.println("thread1:----非守护线程");
}
});
Thread thread2 = new Thread(() -> {
while (true) {
iCount--;
if (iCount <= 0) break;
System.out.println("thread2:----非守护线程");
}
});
Thread thread3 = new Thread(() -> {
//2. 守护thread1、thread2线程
try {
thread1.join();
thread2.join();
System.out.println("thread3:----守护线程");
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
//1.这种守护的是主线程
thread3.setDaemon(true);
thread1.start();
thread2.start();
thread3.start();
}
}
守护线程:show me code
于 2024-05-06 16:04:00 首次发布