event-based code design two approaches to high performance code thread model spawn threads to handle actions reader thread, writer thread threads wait until a task happens mutexes and, thread management usually done using POSIX threads (pthreads) event model open file descriptors for read, write events set up "callbacks" for each file descriptor callbacks handle the data periodically check filedescrpitors wait some predefined period of time (eg 100ms) readable or writable content? if so, send it to the callback handled by poll, select, epoll (linux only), kqueue (bsd), or libevent threads are a pain to debug!