Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Easing upload thread in an applet - how to?

 
Martin Asenov
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys!

Fortunately, the applet I've been bothering you with is almost finished, so I'm done with applets

Anyway, one more final question... I use an upload() method which simply parses file to be uploaded in parts of 5 MBs and posts them to the server. Everything's just fine, excluding the moment when it comes to performing the upload. The entire applet gets frozen, as it does the thing. I know that it's a tough process, but how can I spare some system resources to the GUI itself? I wrapped the upload of every single piece in EventQueue.invokeLater() method, even used the yield() method, and meanwhile print out some text in a JTextArea, but it doesn't seem to get bothered, the entire upload queue is done and then all the output and all the other actions get executed alltogether.

So, my question is how to spare some system resources to the GUI of the applet and perform certain events, no matter that in the same time it makes stream writing and posting to server?

Thanks in advance!
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not executing all that file processing and uploading in the event thread, are you? That should not be used for anything time-consuming, lest the GUI freezes. You can use a FutureTask instead.
 
Martin Asenov
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf, I tried it, but it spares again all the applet's resources only for the upload. Meanwhile, the applet freezes. I want it to be reactable and do some stuff, as it does the upload. But I didn't manage to achieve it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic