Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Multi-Threaded Application

Posted on 2004-08-21
6
Medium Priority
?
182 Views
Last Modified: 2010-03-31
I have what is probably a common problem that many of you have experienced.  I've been coding in Java for only 8 or 9 months so I'm just dangerous enough to cause myself a problem every now and then.  What I'm experiencing is the following:

I've written an application to maintain parts inventory for our company.  It connects to a sql database to retrieve information and every query to the database is triggered by a user action of one sort or another.  On rather large queries that take a little time to process and return data, I would like my swing interface to not stop updatting and still allow user-interaction.

What I "thought" my solution would be is the following:

I implemented runnable on my main-window application (which has several dozen smaller JPanel extended classes within a cardlayout) and then in my main, I just created an instance of the main window class and called .run (which contains MainClass.show() ).

Any ideas?

Thanks,
David
0
Comment
Question by:lomidien
  • 2
  • 2
  • 2
6 Comments
 
LVL 4

Expert Comment

by:91mustang
ID: 11861418
Just run the larger queries in a seperate thread. that may work for you, just a thought
0
 

Author Comment

by:lomidien
ID: 11861626
That handles the queries part of the problem, I believe.  Since I'm already asking about the topic though, what about window refreshing issues (not related to the queries themselves).  What is the best way to go about making the main window threaded so that calls within child windows do not cause the overall application to "freeze" or not repaint properly?

Thanks,
David
0
 
LVL 35

Accepted Solution

by:
girionis earned 2000 total points
ID: 11861702
Hi lomidien,

all repaints and processing in swing components should be made in the event-dispatching thread so it won't cause other components to wait till the main thread finishes. Take a look at the following tutorials:

http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html
http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html
http://java.sun.com/products/jfc/tsc/articles/threads/threads3.html

Regards
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:lomidien
ID: 11861764
Perfect.  Exactly what I was looking for.

Thanks
0
 
LVL 4

Expert Comment

by:91mustang
ID: 11862131
>>That handles the queries part of the problem

Well why not a points split?
0
 
LVL 35

Expert Comment

by:girionis
ID: 11862972
:)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question