wait°ú notify¿¡ ´ëÇؼ­...


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

±Û¾´ÀÌ :¹Ú¹ÎÁÖ 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()ÀÇ ±â´ÉÀº ±âº»ÀûÀ¸·Î ¾Ë°í ÀÖ´Ù´Â ÀüÁ¦ÇÏ¿¡ ¿Ã¸®°Ú½À´Ï´Ù.
·çƾ Á» ²À ¾Ë·ÁÁֽʽÿä...


´ÙÀ½ ±Ûµé:



À̾ ±Û¿Ã¸®±â(´äÇϱâ)

À̸§:
E-Mail:
Á¦¸ñ:
³»¿ë:
HTML ÅÂ±× Æ÷ÇÔ ¿©ºÎ: HTML ¹®¼­ÀÏ °æ¿ì üũ
°ü·Ã URL(¼±ÅÃ):
URL Á¦¸ñ(¼±ÅÃ):
°ü·Ã À̹ÌÁö URL:


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]