• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 22649
126
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
 
See where your hand is? Not there. It's next to this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic