You lock mutex at the strart of the multithreded funtion - all your job performs sequentially one thread after another, just like single threaded application.