Try this mate... (no promises)
IMHO thats about as safe as it gets ATM, if that still causes problems then you could try adding a critical section.
but if you're only going to be doing a bit of math in the callback I'd suggest writing it in C.
Function Callback( threadIndex:Int ) "C" NoDebug Global a:Int[ 2 ] a[ threadindex ] = 3 EndFunction
IMHO thats about as safe as it gets ATM, if that still causes problems then you could try adding a critical section.
but if you're only going to be doing a bit of math in the callback I'd suggest writing it in C.