Github user zentol commented on the issue:
https://github.com/apache/flink/pull/5394
How about calling `Thread.currentThread().interrupt();` only after having
left the loop?
```
public void run(SourceContext<T> ctx) throws Exception {
boolean setInterruptFlag = false;
while (running) {
try {
Thread.sleep(20);
} catch (InterruptedException ignored) {
setInterruptFlag = true;
}
}
if (setInterruptFlag) {
Thread.currentThread().interrupt();
}
}
```
This should behave like the original proposal, without the hot loop.
---