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?

[410 byte] By [cloudswenga] at [2007-10-2 0:13:30]
# 1

> 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)

tswaina at 2007-7-15 16:14:54 > top of Java-index,Java Essentials,Java Programming...
# 2
this might prove to be helpful http://builder.com.com/5100-6370-5144546.html#Listing%20C
kilyasa at 2007-7-15 16:14:54 > top of Java-index,Java Essentials,Java Programming...
# 3

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?

cloudswenga at 2007-7-15 16:14:54 > top of Java-index,Java Essentials,Java Programming...