com.zipwhip.api.signals.sockets.netty.InterruptThreadIfCancelledObserver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zipwhip-api Show documentation
Show all versions of zipwhip-api Show documentation
Java client to support applications powered by the Zipwhip Cloud
The newest version!
package com.zipwhip.api.signals.sockets.netty;
import com.zipwhip.api.signals.sockets.ConnectionHandle;
import com.zipwhip.concurrent.ObservableFuture;
import com.zipwhip.events.Observer;
/**
* Created with IntelliJ IDEA.
* User: Michael
* Date: 9/12/12
* Time: 2:11 PM
*
* Interrupt the thread if cancelled.
*/
public class InterruptThreadIfCancelledObserver implements Observer> {
private final Thread thread;
public InterruptThreadIfCancelledObserver(Thread thread) {
this.thread = thread;
}
public InterruptThreadIfCancelledObserver() {
this(Thread.currentThread());
}
@Override
public void notify(Object sender, ObservableFuture future) {
if (future.isCancelled()) {
thread.interrupt();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy