<div>class MyThread extends Thread{</div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span>JPanel p;</div> <div><span style="white-space:pre;"> </span>JButton b;</div> <div><span style="white-space:pre;"> </span>int lv;</div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span>int t = 0;</div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span>boolean flag = false;</div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span>public MyThread(JPanel p ,JButton b, int lv) {</div> <div><span style="white-space:pre;"> </span>// TODO Auto-generated constructor stub</div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span>this.p = p;</div> <div><span style="white-space:pre;"> </span>this.lv = lv;</div> <div><span style="white-space:pre;"> </span>this.b = b;</div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span>}</div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span>void rLevel(){</div> <div><span style="white-space:pre;"> </span>if(lv == Level.one){</div> <div><span style="white-space:pre;"> </span>t = 1000;</div> <div><span style="white-space:pre;"> </span>}else if(lv == Level.two){</div> <div><span style="white-space:pre;"> </span>t = 500;</div> <div><span style="white-space:pre;"> </span>}else if(lv == Level.three){</div> <div><span style="white-space:pre;"> </span>t = 300;</div> <div><span style="white-space:pre;"> </span>}</div> <div><span style="white-space:pre;"> </span>}</div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span>void finish(){</div> <div><span style="white-space:pre;"> </span>flag = true;</div> <div><span style="white-space:pre;"> </span>}</div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span>@Override</div> <div><span style="white-space:pre;"> </span>public void run() {</div> <div><span style="white-space:pre;"> </span>// TODO Auto-generated method stub</div> <div><span style="white-space:pre;"> </span>while(true){</div> <div><span style="white-space:pre;"> </span>int x = (int)(Math.random() * p.getWidth());</div> <div><span style="white-space:pre;"> </span>int y = (int)(Math.random() * p.getHeight());</div> <div><span style="white-space:pre;"> </span>b.setLocation(x, y);</div> <div><span style="white-space:pre;"> </span>p.add(b);</div> <div><span style="white-space:pre;"> </span>p.repaint();</div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span>try{</div> <div><span style="white-space:pre;"> </span>rLevel();</div> <div><span style="white-space:pre;"> </span>Thread.sleep(t);<span style="white-space:pre;"> </span>// 그냥 숫자쓰면 잘되고 왜 변수선언으로하면 오류걸리는건데 ..아.. 스트레쓰 이빠이</div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span>if(flag == true){</div> <div><span style="white-space:pre;"> </span>p.removeAll();</div> <div><span style="white-space:pre;"> </span>p.repaint();</div> <div><span style="white-space:pre;"> </span>return;</div> <div><span style="white-space:pre;"> </span>}</div> <div><span style="white-space:pre;"> </span>}catch(InterruptedException e){</div> <div><span style="white-space:pre;"> </span>return;</div> <div><span style="white-space:pre;"> </span>}</div> <div><span style="white-space:pre;"> </span>}</div> <div><span style="white-space:pre;"> </span>}</div> <div><br></div> <div>}</div> <div><br></div> <div>여기서 sleep(1000);</div> <div><br></div> <div>이런식으로하면 문제없이 스레드가 잘돌아가는데</div> <div><br></div> <div>저위에코드처럼 t나 다른변수넣으면 에러가 발정난거처럼나요 ㅡ.ㅡ 스트레스 진짜 와ㅏㅏㅏㅏㅏㅏㅏㅏㅏㅏㅏㅏㅏㅏㅏ</div> <div><br></div> <div>어제 밤 10시정도부터 자바 셤공부 빡세게 하고잇는데</div> <div><br></div> <div>아침 8시 되가는데 멘탈 터졋어요 어케해요 ㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜ</div>
<div style="text-align:left;">
<div style="text-align:center;"><img src="http://thimg.todayhumor.co.kr/upfile/201402/1391318675K2QSS3BeVEgNKt8.jpg" width="500" height="751" alt="1.jpg" style="font-size:9pt;line-height:1.5;border:none;"></div>
<div style="text-align:left;">
<div style="text-align:center;"><img_ src="http://thimg.todayhumor.co.kr/upfile/201402/1391318676FvtzyFyCODin9aLlCogJpNSzN2HJWZ.jpg" width="500" height="751" alt="6.jpg" style="font-size:9pt;line-height:1.5;border:none;"></div>
<div style="text-align:left;">
<div style="text-align:center;"><img_ src="http://thimg.todayhumor.co.kr/upfile/201402/1391318675sPCUIgw4MXPGWvKuDFznr.jpg" width="500" height="751" alt="2.jpg" style="font-size:9pt;line-height:1.5;border:none;"></div>
<div style="text-align:center;"><img_ src="http://thimg.todayhumor.co.kr/upfile/201402/1391318676vyiZR1vWoC.jpg" width="500" height="751" alt="5.jpg" style="font-size:9pt;line-height:1.5;border:none;"><img_ src="http://thimg.todayhumor.co.kr/upfile/201402/1391318676UOjCi6H7HfdGjhKHycIWQ5ErgsP5.jpg" width="500" height="751" alt="4.jpg" style="font-size:9pt;line-height:1.5;border:none;"><img_ src="http://thimg.todayhumor.co.kr/upfile/201402/1391318675AON5apAen4g8T9dFiuAe.jpg" width="500" height="751" alt="3.jpg" style="font-size:9pt;line-height:1.5;border:none;"></div></div></div></div>
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.