Proper Threading
From: Mark Haase (mehaase_at_earthlink.net)
Date: 10/28/03
- Next message: David Gavini: "UnsupportedOperationException is thrown inconsistently"
- Previous message: Darryl L. Pierce: "Re: Interface Runnable question (Newbie)"
- Next in thread: Kristian Bisgaard Lassen: "Re: Proper Threading"
- Reply: Kristian Bisgaard Lassen: "Re: Proper Threading"
- Reply: Steve Horsley: "Re: Proper Threading"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 28 Oct 2003 12:12:34 -0500
Hey All--
I've just gotten back into java for a work-study job I have doing some
research. I'm having to refigure out GUI, events, and Threads, since
these have changed significantly since the JDK 1.03 when I used to write
java.
So suspend() and resume() are deprecated now? I can see how they're
dangerous, but why not let programmers assume that danger like any other
threaded runtime environment?
Anyways, what I'm doing now is I have a "running" boolean that tells the
thread whether to do any work, ie:
public void run () {
while (true) {
if (running) {
// do the thread's work
}
try {Thread.sleep(100)}
catch (InterruptedException e) {
System.out.println("Caught error: " + e.toString());
}
}
}
Is this what the makers of Java intended? I feel strange about the while
(true) but this is inside an applet, so I figure that its okay because
the browser will call stop() when its done with the applet, and stop()
always stops the thread.
If this is not ideal, then can somebody point me to a resource that
shows how to do it right?
tia
-- |\/| /| |2 |< mehaase(at)sas(dot)upenn(dot)edu
- Next message: David Gavini: "UnsupportedOperationException is thrown inconsistently"
- Previous message: Darryl L. Pierce: "Re: Interface Runnable question (Newbie)"
- Next in thread: Kristian Bisgaard Lassen: "Re: Proper Threading"
- Reply: Kristian Bisgaard Lassen: "Re: Proper Threading"
- Reply: Steve Horsley: "Re: Proper Threading"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|