elizarov
03/03/2017, 4:34 PMn elements of any type. Let's use `Unit`: val chan = Channel<Unit>(n)
2. Put n elements there intially. These are your permits: repeat(n) { chan.offer(Unit) }
3. When you need a permit receive it from the channel: chan.receive()
4. When you done working, send permit back to channel: chan.send(Unit)