Comparing two remote threads?

view story

http://stackoverflow.com – I am implementing an application which executes two programs in lockstep. Each system call is a synchronization point. An application might have more than one thread, thus I need to identify unequivocally each of them in order to synchronize the execution of a thread from the first application with the execution of the same thread in the second application. Is there a way to identify if two remote threads are executing the same code or function? Every suggestion is welcomed!! :D (HowTos)