PPT Slide
/* The run method changes the value of xpos AND
repaints the screen after a pause of 100 milliseconds */
/* Moving xpos from left to right */
for (xpos = 5; xpos <=105; xpos +=4)
try {Thread.sleep(100); }
catch (InterruptedException e) {}
/* Moving xpos from right to left */
for (xpos = 105; xpos > 5; xpos -=4)
try {Thread.sleep(100); }
catch (InterruptedException e) {}
Why does run have to go to sleep ?