• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Threading in Swing two ways?

 
Ranch Hand
Posts: 67
PHP Debian Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
K i have seen like many people have been using the normal way of implementing the threading(extending from Thread or implement Runnable). But there's also the way to use SwingWorker. Which is to right use ?
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SwingWorker makes the work easier sometimes, with its distinct steps: publish / process for intermediate results, and done when the job is finished.

Still, anything you can do with SwingWorker you can also do yourself with "regular" threads. You'll just have to do more work yourself.
 
mandlar suurla
Ranch Hand
Posts: 67
PHP Debian Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for quick replay, but off curse this isnt my last question . There are also SwingUtilites.invokeLater and SwingUtilites.invokeAndWait, which i know doesn't make new thread, so i dont understand their use in Swing.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by mandlar suurla:
Thank you for quick replay, but off curse this isnt my last question . There are also SwingUtilites.invokeLater and SwingUtilites.invokeAndWait, which i know doesn't make new thread, so i dont understand their use in Swing.


These methods execute a Runnable directly on the event thread; they're intended for short actions that won't delay event processing. In contrast, SwingWorker is for things that will take a long time, but will interact with the GUI occasionally during that time.
 
reply
    Bookmark Topic Watch Topic
  • New Topic