Speed of glTexImage2D

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?

I am not realy sure about a blocking problem but one thing you might look at is how much textures you are feeding to openGL, if you are over filling the texture mem on your vid card its going to do the rendering for that in software, or it will swap data on your vid card, all taking a long time.

When I was creating “game” I created all textures at the startup, before game actually started, so it didn’t affected preformance at runtime. There is TexSubImage to get higher speeds.

BTW, texture is assigned to uint, what will hapen if I call uint t=texture1, use t as texture, then call t=texture2 use t again. I’ve tried that out - works, but what happens with VRAM&RAM?