Often the simplest way to do two things at once is by using
Ruby
threads. These are totally in-process, implemented within the Ruby
interpreter. That makes the Ruby threads completely portable---there
is no reliance on the operating system---but you don't get certain
benefits from having native threads. You may experience thread
starvation (that's where a low-priority thread doesn't get a chance to
run). If you manage to get your threads deadlocked, the whole process
may grind to a halt. And if some thread happens to make a call to the
operating system that takes a long time to complete, all threads will
hang until the interpreter gets control back. However, don't let these
potential problems put you off---Ruby threads are a lightweight and
efficient way to achieve parallelism in your code.