Solved

Multi-Threaded Application

Posted on 2004-08-21
6
179 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jboss 7.1 start up error 1 83
eclipse console opening separately 2 49
maven not picking latest jar instead picking old jar from .m2 12 74
Java array 10 87
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

739 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