The issue here is that the code isn't sharing the array between threads; so because of that, each thread is modifying it's local copy of the array, not the global array as expected. The fix for this problem is to share the variable, and lock it before accessing it during the thread processing:
my @retCodes;
share(@retCodes);
...
#during the thread sub
lock(@retCodes);
push(@retCodes, ($retCode>>8));