Make EventLoop queueing thread safe on the JVM.
- Move f to static function. (better stacktraces).

This change makes it impossible to implement queueLength without locking.
Instead, I replaced it with queueEmpty.