Speed issue with multiple thread because of static variables