You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by "Jim Bonanno (JIRA)" <ji...@apache.org> on 2007/07/31 14:31:52 UTC
[jira] Created: (IVY-585) Add an interruptSafely to Ivy
Add an interruptSafely to Ivy
-----------------------------
Key: IVY-585
URL: https://issues.apache.org/jira/browse/IVY-585
Project: Ivy
Issue Type: Improvement
Components: Core
Affects Versions: 2.0.0-alpha-2
Reporter: Jim Bonanno
I would like to request an implementation of interrupt in the Ivy class that can not call stop on the operatingThread. I am hitting issues trying to interrupt the resolve from a job in an eclipse plugin. I am seeing a ThreadDeath exception in the uncaughtExceptionHandler and then a hung thread.
I would like propose an interruptedSafely that basically just set interrupted to true. This will allow monitoring the operating thread until it terminates without a stop.
/**
* Marks the current running operation as interrupted. The processing will eventually call
* checkInterrupted and end safely.
*/
public void interruptSafely(Thread operatingThread) {
if (operatingThread != null && operatingThread.isAlive()) {
if (operatingThread == Thread.currentThread()) {
throw new IllegalStateException("cannot call interrupt from ivy operating thread");
}
Message.verbose("interrupting operating thread...");
interrupted = true;
}
}
Another option would be to offer getter/setters on the interrupted boolean. Interrupted could then be set and checkInterrupted would end the resolve. Since stop is not the recommended way to stop a thread, it would be nice to have a way to interrupt the resolve that can not call stop.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (IVY-585) Add an interruptSafely to Ivy
Posted by "Jim Bonanno (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/IVY-585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12518215 ]
Jim Bonanno commented on IVY-585:
---------------------------------
I was looking at the code some more and was curious to why checkInterrupted was checking a boolean flag instead of checking Thread.currentThread().isInterrupted(). I believe that the code was implemented this way because if you call interrupted on a thread that has not been started, then isInterrupted returns false. The interrupted support in ivy is very good. This issue is just asking for a interface to interrupt that does not call the join and stop.
The code in my first comment was not correct. The interrupt method must call operatingThread.interrupt to interrupt blocking i/o. But this implementation leaves the join up to the caller and can not call stop.
public void interruptSafely(Thread operatingThread) {
if (operatingThread != null && operatingThread.isAlive()) {
if (operatingThread == Thread.currentThread()) {
throw new IllegalStateException("cannot call interrupt from ivy operating thread");
}
Message.verbose("interrupting operating thread...");
operatingThread.interrupt();
setInterrupted(true);
}
}
> Add an interruptSafely to Ivy
> -----------------------------
>
> Key: IVY-585
> URL: https://issues.apache.org/jira/browse/IVY-585
> Project: Ivy
> Issue Type: Improvement
> Components: Core
> Affects Versions: 2.0.0-alpha-2
> Reporter: Jim Bonanno
>
> I would like to request an implementation of interrupt in the Ivy class that can not call stop on the operatingThread. I am hitting issues trying to interrupt the resolve from a job in an eclipse plugin. I am seeing a ThreadDeath exception in the uncaughtExceptionHandler and then a hung thread.
> I would like propose an interruptedSafely that basically just set interrupted to true. This will allow monitoring the operating thread until it terminates without a stop.
> /**
> * Marks the current running operation as interrupted. The processing will eventually call
> * checkInterrupted and end safely.
> */
> public void interruptSafely(Thread operatingThread) {
> if (operatingThread != null && operatingThread.isAlive()) {
> if (operatingThread == Thread.currentThread()) {
> throw new IllegalStateException("cannot call interrupt from ivy operating thread");
> }
> Message.verbose("interrupting operating thread...");
> interrupted = true;
> }
> }
> Another option would be to offer getter/setters on the interrupted boolean. Interrupted could then be set and checkInterrupted would end the resolve. Since stop is not the recommended way to stop a thread, it would be nice to have a way to interrupt the resolve that can not call stop.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (IVY-585) Add an interruptSafely to Ivy
Posted by "John Gill (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/IVY-585?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
John Gill updated IVY-585:
--------------------------
Description:
I would like to request an implementation of interrupt in the Ivy class that can not call stop on the operatingThread. I am hitting issues trying to interrupt the resolve from a job in an eclipse plugin. I am seeing a ThreadDeath exception in the uncaughtExceptionHandler and then a hung thread.
I would like propose an interruptedSafely that basically just set interrupted to true. This will allow monitoring the operating thread until it terminates without a stop.
{code:java}
/**
* Marks the current running operation as interrupted. The processing will eventually call
* checkInterrupted and end safely.
*/
public void interruptSafely(Thread operatingThread) {
if (operatingThread != null && operatingThread.isAlive()) {
if (operatingThread == Thread.currentThread()) {
throw new IllegalStateException("cannot call interrupt from ivy operating thread");
}
Message.verbose("interrupting operating thread...");
interrupted = true;
}
}
{code}
Another option would be to offer getter/setters on the interrupted boolean. Interrupted could then be set and checkInterrupted would end the resolve. Since stop is not the recommended way to stop a thread, it would be nice to have a way to interrupt the resolve that can not call stop.
was:
I would like to request an implementation of interrupt in the Ivy class that can not call stop on the operatingThread. I am hitting issues trying to interrupt the resolve from a job in an eclipse plugin. I am seeing a ThreadDeath exception in the uncaughtExceptionHandler and then a hung thread.
I would like propose an interruptedSafely that basically just set interrupted to true. This will allow monitoring the operating thread until it terminates without a stop.
/**
* Marks the current running operation as interrupted. The processing will eventually call
* checkInterrupted and end safely.
*/
public void interruptSafely(Thread operatingThread) {
if (operatingThread != null && operatingThread.isAlive()) {
if (operatingThread == Thread.currentThread()) {
throw new IllegalStateException("cannot call interrupt from ivy operating thread");
}
Message.verbose("interrupting operating thread...");
interrupted = true;
}
}
Another option would be to offer getter/setters on the interrupted boolean. Interrupted could then be set and checkInterrupted would end the resolve. Since stop is not the recommended way to stop a thread, it would be nice to have a way to interrupt the resolve that can not call stop.
> Add an interruptSafely to Ivy
> -----------------------------
>
> Key: IVY-585
> URL: https://issues.apache.org/jira/browse/IVY-585
> Project: Ivy
> Issue Type: Improvement
> Components: Core
> Affects Versions: 2.0.0-alpha-2
> Reporter: Jim Bonanno
>
> I would like to request an implementation of interrupt in the Ivy class that can not call stop on the operatingThread. I am hitting issues trying to interrupt the resolve from a job in an eclipse plugin. I am seeing a ThreadDeath exception in the uncaughtExceptionHandler and then a hung thread.
> I would like propose an interruptedSafely that basically just set interrupted to true. This will allow monitoring the operating thread until it terminates without a stop.
> {code:java}
> /**
> * Marks the current running operation as interrupted. The processing will eventually call
> * checkInterrupted and end safely.
> */
> public void interruptSafely(Thread operatingThread) {
> if (operatingThread != null && operatingThread.isAlive()) {
> if (operatingThread == Thread.currentThread()) {
> throw new IllegalStateException("cannot call interrupt from ivy operating thread");
> }
> Message.verbose("interrupting operating thread...");
> interrupted = true;
> }
> }
> {code}
> Another option would be to offer getter/setters on the interrupted boolean. Interrupted could then be set and checkInterrupted would end the resolve. Since stop is not the recommended way to stop a thread, it would be nice to have a way to interrupt the resolve that can not call stop.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.