title: How to stop long running disk operation in Thread or Coroutine in Android?
body: <p>Let's say we have this pseudo code in Android:</p>
  <pre><code>fun writeData(fd: File, data: Data) {
      timeout (1000) { //max running time is limited to 1000ms
          val operation = create thread/coroutine { // Thread or Coroutine
              Os.write(fd, data) // &lt;--- let say it's blocking operation for 2 minutes
          }.start()
      }
  }
  </code></pre>
  <p>How can I immediately stop <code>Thread</code> or <code>Coroutine</code>? When I call <code>operation.interrupt()</code> (<code>operation.cancel()</code> in the case of coroutine) <code>thread</code> or <code>coroutine</code> is waiting to be completed and running 2 minutes (all the time until <code>Os.write(fd, data)</code> is finished). I need to abort operation immediately, because it is a long disk operation (don't want to wait 2 minutes).</p>