Make a 'lock'. When a thread beings to do something to the variable, 'lock' it. When it is finished, unlock it.
Code:
struct buffer
{
char buf[BUFSIZE];
long int threadLock;
} globalBuffer;
long int bufferText( long int caller, char *text )
{
if( globalBuffer.threadLock != -1 )
{
globalBuffer.threadLock = caller;
memset( globalBuffer.buf, '\0', BUFSIZE );
strncpy( globalBuffer.buf, text, strlen( text ) );
}
return globalBuffer.threadLock;
}
There. Now you can lock your thread with the number for the particular thread. When you're done, make an unlock function that sets the variable to -1.
Quzah.