Spawn vs Fiber.new

This may be dummy question. I tried both spawn and Fiber.new and I do see they behave differently in some cases and I am sure I am not the first one to see this. All I can find about spawn in docs is Top Level Namespace - github.com/crystal-lang/crystal

Is there any documentation that explains their differences in crystal that I can refer to?

Fiber.new is not aimed to be used as a public api in general. Use spawn. Spawn uses Fiber.new plus schedules the fiber for execution.

If you are developing something that needs to interact with the runtime in some very specific way for sure use Fiber.new, but in general spawn should be enough.

3 Likes

Thanks for clarifying @bcardiff, this helps