• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need a Solution

 
Sarah Haideri
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an old applet which loads image. What can be done to increase the refresh rate? I know it contains some deprecated methods of Thread class. What can be done to stop using those methods?
Here is source code. Can someone update it to increase the refresh rate and get rid of the deprecated methods?
Thanks.
 
Rajinder Yadav
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sarah if you want a better response, maybe you should try posting this in the Applet or one of the Java In General forums As this forum is only related to questions on the SCJP Exam
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, I'm moving this to the Applet forum.
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gee I'd like to help, but I don't know to which of the FIVE forums in which you posted this exact same question I should respond. :roll:
[ February 26, 2002: Message edited by: Rob Ross ]
 
Sarah Haideri
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you reply here if you know?
Thanks.
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As to increasing the refresh rate, why don't you not sleep for a second in your loop? that seems like it would certainly speed things up.
As for suspend/resume, well you can just stop using them. If you want to get the same effect in your thread, you could add a global variable to the class like "sleep", and set this to true when your applet gets a stop() event. In your image thread, you can check for this boolean in your loop and when it's true, you call sleep(0); that will have the same effect as suspend(). Then in your start() method, you can call interrupt() on the image thread, which will wake it up, similar to resume.
Another way to design this is to have an image thread just continuously get the image and save it to a buffer, then set a global boolean to true, and another repaint thread that continuously checks this boolean, and when it's true:
1. sets it to false
2. copies the buffer to your image area and calls repaint. That way the image is only refreshed when there is a new image to paint.
[ February 26, 2002: Message edited by: Rob Ross ]
 
Sarah Haideri
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob for the reply. Can you please change the code so that it does what you are suggesting?
Thanks a lot.
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, sorry. You should be able to do it yourself though with the information I have given you.
Good luck!
[ February 26, 2002: Message edited by: Rob Ross ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic