thread safty queue template