in reply to Threads sharing global variable

Note also that the expression int(rand() * 100) generates a number in the range 0..99 (inclusive). For non-zero value, you'll want to add one:

$a = 1 + int rand 100;