</code>.</p>
      <p class="first">Here is a shutdown hook example in Java:</p>
            <pre class="line-numbers"><code class="language-java">// Add shutdown hook to stop the Kafka Streams threads.
// You can optionally provide a timeout to `close`.
Runtime.getRuntime().addShutdownHook(new Thread(streams::close));</code></pre>
      <p>After an application is stopped, Kafka Streams will migrate any tasks that had been running in this instance to available remaining
        instances.</p>
</div>

      