Solved

Multi-Threaded Application

Posted on 2004-08-21
6
175 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
Comment Utility
Just run the larger queries in a seperate thread. that may work for you, just a thought
0
 

Author Comment

by:lomidien
Comment Utility
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
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:lomidien
Comment Utility
Perfect.  Exactly what I was looking for.

Thanks
0
 
LVL 4

Expert Comment

by:91mustang
Comment Utility
>>That handles the queries part of the problem

Well why not a points split?
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
:)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now