A little better thread handshaking for JVM and Mac
Fix compile error