4

I understand that if there are two or more threads sharing a single X display connection, XInitThreads must be called before any other Xlib call.

But what if every thread has its own connection to the display and operates only on that connection? Is XInitThreads still necessary? And does it make difference if I use the GLX extension?

hpsMouse
  • 2,004
  • 15
  • 20

1 Answers1

1

From the documentation:

It is only necessary to call this function if multiple threads might use Xlib concurrently. If all calls to Xlib functions are protected by some other access mechanism (for example, a mutual exclusion lock in a toolkit or through explicit client programming), Xlib thread initialization is not required. It is recommended that single-threaded programs not call this function.

So, it seems that even if the threads use different connections, XInitThreads must be called.

I suggest you to call XInitThread just before you create your threads. This way everything should be OK.

johnfound
  • 6,857
  • 4
  • 31
  • 60