interrupt a time-consuming operation
Hi,
I got a sperate thread running a time-consuming operation, but there's no loop inside run() (actually calling a remote method at backend through CORBA), which means I couldn't check a flag variable or interrupted() periodically inside the run(). So the thread couldn't be notified that the user has call interrupt() on this thread. Then how can I really interrupt the run() on the half way?
> Hi,
>
> I got a sperate thread running a time-consuming
> operation, but there's no loop inside run() (actually
> calling a remote method at backend through CORBA),
> which means I couldn't check a flag variable or
> interrupted() periodically inside the run(). So the
> thread couldn't be notified that the user has call
> interrupt() on this thread. Then how can I really
> interrupt the run() on the half way?
You have to call Thread.Interrupt() on the Object.
(T)
but calling interrupt() on the object only set the thread to interrupted state, instead of stopping its running. The run() method should have a way to detect the interrupted state and escape from the run() method once set interrupted. This is a real interruption. But my question is that I couldn't find a periodical way to check the interrupted state inside run(), because there's not a loop in the work I want to do in a seperate thread. It's a remote method call through CORBA.
How can I get around this?