Moved philosopher behavior to a function.