Re: How Do I Make My Application "Feel" Faster
- From: "Jason Cavett" <jason.cavett@xxxxxxxxx>
- Date: 30 Nov 2006 07:17:31 -0800
On Nov 30, 9:59 am, "Steve W. Jackson" <stevewjack...@xxxxxxxxxxx>
wrote:
In article <1164895786.940642.122...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"Jason Cavett" <jason.cav...@xxxxxxxxx> wrote:
[ snip ]
So, I attempted to create a thread in my actionPerformed with the
following code:
Thread appThread = new Thread() {
public void run() {
try {
model.openProject();
} catch (Exception e) {
e.printStackTrace();
}
}
};
appThread.run();
However, the menu still seems a little sluggish. Am I approaching thisline just like any other method. Instead, call "appThread.start()" in
the right way? (I was never very strong with Threads, so things get a
little fuzzy here for me.)When you call the run method of a Thread object, it simply executes in
your code, which causes the Thread object to run in its own separate
thread -- which was your goal. Then appThread will exist independently
of your actionPerformed method and the EDT on which it was invoked, and
will become eligible for garbage collection when its run method
completes.
Alternatively, you could create a Runnable instead of a Thread. If you
actually want to spawn it separately, you can then pass that Runnable as
the parameter to a Thread constructor and call start on the Thread. But
if you should need, as I did in some situations, to have it run on the
EDT, you could pass that Runnable to EventQueue.invokeLater.
= Steve =
--
Steve W. Jackson
Montgomery, Alabama- Hide quoted text -- Show quoted text -
That works great! :-) Thank you.
.
- References:
- How Do I Make My Application "Feel" Faster
- From: Jason Cavett
- Re: How Do I Make My Application "Feel" Faster
- From: Steve W. Jackson
- Re: How Do I Make My Application "Feel" Faster
- From: Jason Cavett
- Re: How Do I Make My Application "Feel" Faster
- From: Steve W. Jackson
- How Do I Make My Application "Feel" Faster
- Prev by Date: Re: How Do I Make My Application "Feel" Faster
- Next by Date: Re: Listening to Mouse leaving a Frame
- Previous by thread: Re: How Do I Make My Application "Feel" Faster
- Next by thread: Re: How Do I Make My Application "Feel" Faster
- Index(es):
Relevant Pages
|