glTexImage2D speed

Hello, I have a project where threads are started and stopped without my knowing so. Some of these threads may be rendering to OpenGL. Which means that they’ll load a background. However, the problem is that glTexImage2D is very slow. Sometimes it’s fast (in the order of 100-200 ms) but sometimes it’s really slow (in the order of 6 seconds!). This is purely random. I assume it has to do with the fact that it can’t access the hardware. So is there anyway to synchronize these activities, as in tell the OpenGL hardware to be ready for a texture? The same happens for when I create the list for the drawing of the backgroudn (however maximum is aroudn 2 seconds). This does not, however, happen when I start loading in my true type fonts( using freetype2 and FTGL).

Any suggestions?
Thanks