title: Reactor core: infinite Flux does not work with several subscribers
body: <p>I'm sorting out with <a href="http://www.baeldung.com/reactor-core" rel="nofollow noreferrer">React core</a> and trying to create '<a href="http://projectreactor.io/docs/core/snapshot/reference/#reactor.hotCold" rel="nofollow noreferrer">hot</a> infinite' Flux with several subscribers:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Test
  public void hotStream() throws InterruptedException {
  
    AtomicInteger counter = new AtomicInteger();
  
    Flux&lt;Object&gt; flux = Flux
        .create(fluxSink -&gt; {
          while (counter.incrementAndGet() &lt;= 10) {
            try {
              TimeUnit.MILLISECONDS.sleep(100);
            } catch (InterruptedException ignored) {
            }
            fluxSink.next(System.currentTimeMillis());
          }
        }).log()
        .publish()
        .autoConnect();
  
    // first subscriber
    new Thread(() -&gt; {
      log.info("[S] Subscribing first");
      flux.log().subscribe(s -&gt; log.info("[*] S1: {}", s));
    }).start();
  
    Thread.sleep(450);
  
    // second subscriber
    new Thread(() -&gt; {
      log.info("[S] Subscribing second");
      flux.log().subscribe(s -&gt; log.info("[*] S2: {}", s));
    }).start();
  }
  </code></pre>
  
  <p>But when the second subscriber has subscribed to the flux then process is stopping:</p>
  
  <pre class="lang-shell prettyprint-override"><code>00:56:03.231 [main] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
  00:56:03.261 [Thread-0] INFO io.github.cepr0.demo.ReactiveTests - [S] Subscribing first
  00:56:03.273 [Thread-0] INFO reactor.Flux.AutoConnect.2 - onSubscribe(FluxPublish.PublishInner)
  00:56:03.279 [Thread-0] INFO reactor.Flux.AutoConnect.2 - request(unbounded)
  00:56:03.286 [Thread-0] INFO reactor.Flux.Create.1 - onSubscribe(FluxCreate.BufferAsyncSink)
  00:56:03.292 [Thread-0] INFO reactor.Flux.Create.1 - request(256)
  00:56:03.403 [Thread-0] INFO reactor.Flux.Create.1 - onNext(1526939763402)
  00:56:03.403 [Thread-0] INFO reactor.Flux.AutoConnect.2 - onNext(1526939763402)
  00:56:03.403 [Thread-0] INFO io.github.cepr0.demo.ReactiveTests - [*] S1: 1526939763402
  00:56:03.403 [Thread-0] INFO reactor.Flux.Create.1 - request(1)
  00:56:03.504 [Thread-0] INFO reactor.Flux.Create.1 - onNext(1526939763504)
  00:56:03.504 [Thread-0] INFO reactor.Flux.AutoConnect.2 - onNext(1526939763504)
  00:56:03.504 [Thread-0] INFO io.github.cepr0.demo.ReactiveTests - [*] S1: 1526939763504
  00:56:03.504 [Thread-0] INFO reactor.Flux.Create.1 - request(1)
  00:56:03.605 [Thread-0] INFO reactor.Flux.Create.1 - onNext(1526939763605)
  00:56:03.605 [Thread-0] INFO reactor.Flux.AutoConnect.2 - onNext(1526939763605)
  00:56:03.605 [Thread-0] INFO io.github.cepr0.demo.ReactiveTests - [*] S1: 1526939763605
  00:56:03.605 [Thread-0] INFO reactor.Flux.Create.1 - request(1)
  00:56:03.706 [Thread-0] INFO reactor.Flux.Create.1 - onNext(1526939763706)
  00:56:03.706 [Thread-0] INFO reactor.Flux.AutoConnect.2 - onNext(1526939763706)
  00:56:03.707 [Thread-0] INFO io.github.cepr0.demo.ReactiveTests - [*] S1: 1526939763706
  00:56:03.707 [Thread-0] INFO reactor.Flux.Create.1 - request(1)
  00:56:03.713 [Thread-1] INFO io.github.cepr0.demo.ReactiveTests - [S] Subscribing second
  00:56:03.714 [Thread-1] INFO reactor.Flux.AutoConnect.3 - onSubscribe(FluxPublish.PublishInner)
  00:56:03.714 [Thread-1] INFO reactor.Flux.AutoConnect.3 - request(unbounded)
  </code></pre>
  
  <p>I expected that the second subscriber will start reading the stream <strong>along with the first subscriber</strong>. But this does not happen.</p>
  
  <p>Could please someone explain why this is happening and how to solve it?</p>
  
  <p><strong>UPDATED</strong></p>
  
  <p>All I had to do is add the following line to the end of the test to prevent it from stopping:</p>
  
  <pre><code>Thread.currentThread().join();
  </code></pre>