Can I interrupt a worker thread?
Marc-André Laverdière
marcandre.laverdiere at gmail.com
Sat Aug 14 08:05:51 EDT 2010
This is an interesting thing. I am also wondering how to have
'cancellable' processing. The cancellation event would be once I get a
disconnection.
Since you are likely to be using a thread pool, its a bit hard to know
which thread to call.
By the way, your handler can be executed from different threads, so
storing it wouldn't help.
Interrupting a thread is a bit of an overkill way of informing your
handler, I find. What about having an AtomicBoolean that you check
regularly?
Justin, is there a way we could have this kind of functionality
built-in Netty's API?
Marc-André LAVERDIÈRE
"Perseverance must finish its work so that you may be mature and
complete, not lacking anything." -James 1:4
mlaverd.theunixplace.com/blog
/"\
\ / ASCII Ribbon Campaign
X against HTML e-mail
/ \
2010/8/14 Nitrostar <nitrostar1 at gmail.com>:
>
> Hi,
>
> Can I interrupt a worker thread? What I'm trying to achieve is unnecessary
> computation after I've timed out for a given request.
>
> I have a TimerTask on every incoming http request. If it fires, I want to
> return an error and kill the current Thread processing that request.
>
> In my setup I have a request object that is constructed in my handler's
> messageReceived method. I'm thinking about storing the Thread that's
> servicing the request in this object and calling interrupt on it if the
> TimerTask expires. I would obviously make sure my TimerTask doesn't fire if
> I've already sent a response back.
>
> Thanks,
> Nitro
> --
> View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Can-I-interrupt-a-worker-thread-tp5422043p5422043.html
> Sent from the Netty User Group mailing list archive at Nabble.com.
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>
More information about the netty-users
mailing list