This article was originally published on DEV.TO. It might be more readable there, due to the native markdown and syntax highlighting support. The repo with the full source code can be found here.

Introduction

Coroutines are functions that yield and execute cooperatively, the concept that has been around for many decades. According to Wikipedia, coroutines are very similar to threads. However, coroutines are cooperatively multitasked, whereas threads are typically preemptively multitasked.

Coroutines are useful for script-like scenarios where the code execution flow can be suspended and resumed after each logical step. …

About

Andrew Nosenko

Dad, a startup founder, ex-Principal Software Engineer at Nuance Communications

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store