wood burning stoves 2.0*
The moose likes Applets and the fly likes Would you use SwingWorker in an applet? Problem with Java 1.5 browser plugin Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Would you use SwingWorker in an applet? Problem with Java 1.5 browser plugin" Watch "Would you use SwingWorker in an applet? Problem with Java 1.5 browser plugin" New topic
Author

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

Daniel Stuart
Greenhorn

Joined: Mar 17, 2008
Posts: 3
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

Joined: Mar 06, 2001
Posts: 13459

"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

Joined: Mar 17, 2008
Posts: 3
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

Joined: Mar 17, 2008
Posts: 3
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Would you use SwingWorker in an applet? Problem with Java 1.5 browser plugin