Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

General Threading!  RSS feed

 
Joe Meany
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey there guys!

I am working with swing for the first time( yes it has been an ongoing couple of weeks of "first-time") and i am in the process of speeding up my program. From what i read online, threading is a great way to do this!

The GUI i have created has a few buttons that execute database queries, and replace text on tables. The database queries are very speed, but the other actions take a very long time.

There are a few cases like this when i think i should call my methods like upDateTable() and PopulateTable().

Would you agree? just looking for some advice, and some positive reinforcement if this is a good place to try threading for the first time.
 
Rob Camick
Ranch Hand
Posts: 2753
11
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A separate Thread is used for long running tasks to the GUI doesn't freeze while waiting for the task to finish.

Generally a database access is considered a long running task since accessing the database and transmitting the data (which could be local or on the internet), takes a relatively long time compared to simply painting a component on the GUI.

So yes this is a good place to start. Read the section from the Swing tutorial on Concurrency. A Swing Worker is a good place to start.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!