Optimized performance for multi-threading (even single thread is quite fast) (~36 sec to run 10000 messages).