• 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

when to use threads in swing applications?

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when to use threads in swing applications? and how to improve the performance of the swing application?
 
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
Mostly when an event (like a button press) requires the execution of code that takes a long time. If you don't put that into a new thread, your application appears to hang, and will not even repaint itself.
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, I think that most of the time, threads don't improve the performance of the Swing app per se, but instead improves the responsiveness. Meaning, a background thread will not likely make a method perform any faster, but will prevent the EDT, the main Swing thread concerned with user interaction and with drawing, from getting bogged down by some long calculation, and this will allow the Swing GUI to still be able to interact with the user.

Abhishek Reddy wrote:when to use threads in swing applications? and how to improve the performance of the swing application?

 
Abhishek Reddy
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the reply, so every event(action,item,mouse,key) has to be handled in a separate thread....
i had developed swing application using netbeans IDE, and i haven't considered to handle the event associated with swing components in a separate thread....
Is there any further steps, i have to consider for improving the performance and quick response of the swing applicaion...




 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Abhishek Reddy wrote:thanks for the reply, so every event(action,item,mouse,key) has to be handled in a separate thread....



Not every event, only those which are time consuming.
Or when it is intentional.
Imagine a scenario where you do not want the user to edit any stuff until he is successfully logged in.
In such kind of scenarios, you can intentionally block the UI till something has happened.
Remember though, that good usability dictates, the user should have the option of canceling any operation.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Recommended reading:
Concurrency in Swing
 
Destroy anything that stands in your way. Except this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic