package com.test0614;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.TextArea;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Calendar;
public class Test7 extends Frame implements Runnable {
private TextArea ta=new TextArea();
public Test7(){
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
add(ta, BorderLayout.CENTER);
setSize(400,400);
setVisible(true);
}
public static void main(String[] args) {
Thread t=new Thread(new Test7());
t.start();
}
@Override
public void run() {
while(true){
Calendar cal=Calendar.getInstance();
String s=String.format("%tF %tT", cal, cal);
setTitle(s);
try{
Thread.sleep(10);
}catch(Exception e){
}
}
}
}
=============================================================
결과)
제목 표시줄에 실시간으로 표시된다.
'자바 DB 연동 > 쓰레드' 카테고리의 다른 글
쓰레드를 이용한 간단한 출금 (0) | 2013.06.19 |
---|---|
쓰레드 interrupt / isAlive (0) | 2013.06.19 |
데몬스레드 (0) | 2013.06.19 |
쓰레드 synchronized(동시에 일하는 것을 막는다) (0) | 2013.06.19 |
자바 쓰레드 (0) | 2013.06.19 |