Re: How Do I Make My Application "Feel" Faster





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 this
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
line just like any other method. Instead, call "appThread.start()" 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.

.



Relevant Pages

  • Re: How Do I Make My Application "Feel" Faster
    ... Thread appThread = new Thread{ ... which causes the Thread object to run in its own separate ... Steve W. Jackson ...
    (comp.lang.java.gui)
  • Re: Printing non-adjacent cells on a single sheet
    ... Steve ... >> Excel worksheet onto a single sheet. ... >> printed on a separate sheet. ... >> hide the columns separating the ranges. ...
    (microsoft.public.excel.newusers)
  • Re: Insurers warn on car alterations .
    ... much like they were saying: ... the hundreds of completely different people who are completely separate ... individuals who both disagree with you;-) ... as steve e.g lives near alton, manchester, Newcastle, switzerland ...
    (uk.transport)
  • Re: If Function containing VLook up
    ... Try to compare 2 visible equal ... are both tables on same sheet or on separate ones) ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Mirroring /var
    ... On Sun, 26 Feb 2006, Steve wrote: ... install that sliced up with a separate /var..... ... The first thing I sysadmins do on receipt of a ...
    (comp.sys.sun.admin)