java - Difference between calling stop from applet menu and restart in appletviewer -
have animation program using threads , applet.
when call stop option applet menu in appletviewer program works when press restart there abnormality in working. thread not come out of while loop on calling restart @ line no.34
class saver { . . public void run() { system.out.println("run "+thread.currentthread().getname()); func(); system.out.println("out of synchronized block"); } synchronized public void func() { int i; while(running) { for(i=0;i<4;i++) { gap[i]+=10; if(gap[i]==360) gap[i]=0; system.out.println(thread.currentthread().getname()); calc(gap[i],400,i%2==0?(byte)1:(byte)-1); yb[i]=(int)(y)+yc; xb[i]=(int)(x)+xc; } repaint(); try { thread.sleep(1000); } catch(exception e) {} } system.out.println("out of while in synchronized block");//not being printed }
Comments
Post a Comment