📄 maskingthread.java
字号:
public class MaskingThread extends Thread {
private boolean stop = false;
private String prompt;
private int time;
public MaskingThread(String prompt, int time){
//传入提示符和刷新间隔时间
this.prompt=prompt;
this.time=time;
}
public void run() {
while(!stop) {
try {
sleep(time);
}catch (InterruptedException e) {
e.printStackTrace();
}
if(!stop){
//执行刷新
// “\b”前面有两个空格
System.out.print("\r" + prompt + " \b\b"); }
System.out.flush();
}
}
//停止线程
public void stopMasking() {
this.stop = true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -