Closed
Description
Given the reproduction below, I'm expecting second
to be printed first in the console. However, the following program blocks on the first effect, printing:
first
second
finished
I believe the issue is on this line, as start
won't fork the effect until an async operation takes place. The call to start
should be replaced with startConcurrently
in order for the fiber to be forked immediately.
Note that runToFuture
also uses start
, and I think it should probably be changed
Repro
import zio.*
def fork(f: UIO[Unit]) = Unsafe.unsafely(Runtime.default.unsafe.fork(f))
val f1 = ZIO.succeed {
Thread.sleep(1000)
println("first")
}
val f2 = ZIO.succeed {
println("second")
}
@main def run = {
fork(f1)
fork(f2)
Thread.sleep(2000)
println("finished")
}
Metadata
Metadata
Assignees
Labels
No labels