dcsimg
Optimizing a graphical thread
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Andre_TheMunchkin
Posted On:   Tuesday, February 5, 2002 12:03 PM

I've written a class that extends Canvas and implements Runnable. Over the years working with various flakey VMs I've gotten in the habit of checking to make sure the temp Graphics I have just "gotten" does not go null, and checking that the thread itself didn't suddenly go null, but I'm wondering if anyone can tell me if these concerns are now unfounded? Specifically, my run() method includes loops that look like: Graphics imgG = myApplet.img.getGraphics(); while(thread!=null && xOff <250 && imgG!=null && !abort){ imgG.copyArea(xOff,yOff,250-xOff,250-yOff,1,1); xOff+   More>>

I've written a class that extends
Canvas and implements Runnable. Over
the years working with various flakey
VMs I've gotten in the habit of
checking to make sure the temp Graphics
I have just "gotten" does not go null,
and checking that the thread itself
didn't suddenly go null, but I'm
wondering if anyone can tell me if
these concerns are now unfounded?
Specifically, my run() method
includes loops that look like:


Graphics imgG = myApplet.img.getGraphics();

while(thread!=null && xOff <250 && imgG!=null && !abort){


    imgG.copyArea(xOff,yOff,250-xOff,250-yOff,1,1);

    xOff++;

    yOff++;


}


I'm using the boolean "abort" because sometimes
when I call the "stop()" method I get
access exceptions, but by changing this boolean,
I can drop out of the run() method without
exceptions.


Can I check the thread and imgG variables
less often now, or is this dangerous?

   <<Less
About | Sitemap | Contact