Call XInitThreads once before the first Xlib call. Suggested by Brian Griffin.