잘만 구현하면 좋은 프로그램을 만들수있겠다~~ ^0^
[Test.java]
interface Listener
{
public void startListener(String log);
public void runListener(String log);
}
class Test2 implements Listener {
public synchronized void startListener(String log) {
System.out.println("Bclass started:"+log);
}
public synchronized void runListener(String log) {
System.out.println("Bclass running:"+log);
}
Test2() {
Bclass myb = new Bclass(this);
Thread thread = new Thread(myb);
thread.start();
}
public static void main(String[] args) {
Test2 t2 = new Test2();
}
}
----------------------------------------------------------------------------
[Bclass.java]
public class Bclass implements Runnable{
private Listener listener;
private int i = 0;
Bclass(Listener l) {
this.listener = l;
this.listener.startListener ("메롱이당 ㅋㅋㅋ 요이땅~~~");
}
public void run() {
while (true) {
this.i++;
try{Thread.sleep(10);}catch (Exception e) {}
this.listener.runListener(i+"--나지금 돌고 있니~ ㅋㅋㅋㅋ");
}
}
}
'컴퓨터/IT' 카테고리의 다른 글
분류는 안되?? (0) | 2008.01.26 |
---|---|
워드 2007 워드 게시테스트 (0) | 2008.01.26 |
eclipse에서 메모리 누수 찾기등.. tptp 플러그인 (0) | 2007.12.31 |
특정일 지난 로그파일 지우기 (3) | 2007.12.31 |
cron 등록시 root가 localhost로 이메일 보내는것 없애는 방법 (0) | 2007.12.24 |