Optimisated multithread algoritm