Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Would you use SwingWorker in an applet? Problem with Java 1.5 browser plugin

 
Daniel Stuart
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a Java applet that used the Java 6 SwingWorker class. It needed to perform a long-running task which updates the GUI as it progresses AND has the ability to be paused and resumed as many times as the user likes.

Unfortunately, I also need to cater to users who might have a Java 1.5 browser plugin, so I rewrote quite a bit of the applet to get it running using a the older SwingWorker class (http://java.sun.com/products/jfc/tsc/articles/threads/src/SwingWorker.java) which was NOT part of the API. It is quite different to the API version but I did get a version working properly when tested with appletviewer.

The problem is that once I use this SwingWorker version with a browser, particularly with a Java 1.5 plugin, the applet sometimes hangs after pause and resume is used. Sometimes.

I suspect that when the applet hangs, it is after the interrupt had been fired during a particular activity in the long running process, perhaps file I/O.

Can anyone comment on this behaviour or provide any insight? I would also appreciate an opinion on the widsom (or lack of) getting rid of the (older) SwingWorker class and trying to program the worker thread by hand.

Thanks
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"oneiota",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted.
 
Daniel Stuart
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry - I thought I had already filled this in when I registered, but I see that it has used my login name instead. I've made the change to the profile.
 
Daniel Stuart
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that setting the worker to null after invoking the interrupt() takes care of the problem. It's not clear why this would be so in the pre-Java6 version of SwingWorker, so comments welcome!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic