Ali*_*sam 3 java swing multithreading
我使用以下代码,JLabel用相同的句子替换每0.5秒,但用另一个点.
Runnable r1=new Runnable() {
@Override
public void run() {
while(true){
try {
connectionStatus.setText("Connection Established...");
Thread.sleep(500L);
connectionStatus.setText("Connection Established.");
Thread.sleep(500L);
connectionStatus.setText("Connection Established..");
Thread.sleep(500L);
} catch (InterruptedException ex) {
}
}
}
};
Thread th1=new Thread(r1);
th1.start();
Run Code Online (Sandbox Code Playgroud)
这是使用线程的真正目的吗?这会影响程序的速度吗?如果我正在做的事情是如此愚蠢,还有其他方法来做这些愚蠢的事情吗?
| 归档时间: |
|
| 查看次数: |
345 次 |
| 最近记录: |