±Û¾´ÀÌ :¹Ú¹ÎÁÖ 2000³â 5¿ù 28ÀÏ 19:33:40
ÀÏ´Ü ¼Ò½º¸¦ º¸½Ã¸é, ÀÌ ¼Ò½º´Â È帣´Â ¹®ÀÚ¿¿¡ ´ëÇÑ ÇÁ·Î±×·¥À̱¸¿©. ¸¶¿ì½º¸¦ ´©¸£¸é ¹®ÀÚ¿ÀÇ ¿òÁ÷ÀÓÀÌ ¸ØÃß¾ú´Ù°¡ ´Ù½Ã ´©¸£¸é ¿Ô´ø ¹æÇâÀ¸·Î µÇµ¹¾Æ°¡´Â ±â´ÉÀ» °¡Áö°í ÀÖ½À´Ï´Ù.±×·±µ¥,±× Áß stop()°ú run(), mousePressed()ºÎºÐ¿¡¼ »ç¿ëµÈ ½º·¹µåÀÇ wait()°ú notify()¸Þ¼ÒµåÀÇ ¿ªÇÒÀÌ Á¤È®È÷ ÀÌÇØ°¡ °¡Áö ¾Ê½À´Ï´Ù. ¾Æ¸¶µµ ÀÌ µÎ ¸Þ¼Òµå¸¦ ÅëÇؼ ¹®ÀÚ¿ÀÇ ¿òÁ÷ÀÓÀ» Á¶ÀýÇÏ´Â °Í °°Àºµ¥ ¸»ÀÌÁ®...
¸ÕÀú ¼Ò½º¸¦ º¸½Ã¸é,
public synchronized void stop() {
kicker = null;
if (threadSuspended) {
threadSuspended=false;
notify();
}
}
public void run() {
Thread.currentThread().setPriority (Thread.MIN_PRIORITY);
while (kicker == Thread.currentThread() ) {
try {
Thread.sleep(delay);
synchronized(this) {
while (threadSuspended)
wait(); <- ÀÌ ºÎºÐ
}
}
catch (InterruptedException e){}
repaint();
}
}
public synchronized void mousePressed(MouseEvent e) {
threadSuspended = !threadSuspended;
if (!threadSuspended) {
hDirection*=-1;
notify(); <- ÀÌ ºÎºÐ
}
}
Ç¥½ÃÇÑ °÷ Áß ¹®ÀÚ¿ÀÇ ¿òÁ÷ÀÓÀ» ¸ØÃß°Ô ÇÏ´Â ºÎºÐÀÌ Á¤È®ÀÌ ¾î´À ¸Þ¼ÒµåÀÎÁö ¸»ÀÌÁ®...
wait()°ú notify()ÀÇ ±â´ÉÀº ±âº»ÀûÀ¸·Î ¾Ë°í ÀÖ´Ù´Â ÀüÁ¦ÇÏ¿¡ ¿Ã¸®°Ú½À´Ï´Ù.
·çƾ Á» ²À ¾Ë·ÁÁֽʽÿä...