Using Ruby 2.5's IO#close

IO class is the basis for all input and output. You can use the public methods of IO class to open, write, read and close the IO stream. The close method makes the IO stream unavailable for any further data operations.
Ruby’s IO#close which would earlier raise an error with message “stream closed”, but it is refined to “stream closed in another thread”. The new message is more clear for the user.

In the above example we close the read stream before the thread has finished its execution and an IOError is raised with message “closed stream” for both Ruby 2.4.0 & Ruby 2.5.0.

Didn’t we try to close the stream in other thread besides the main ruby thread? No, I don’t think we did.
Can we tell the thread scheduler that “hey, please pass the execution to another thread other than the one which is currently running”? Yes, we can using