The lock statement ensures that one thread does not enter a critical section of code while another thread is in the critical section. However, it won\'t work if the workload is
Since a network of machines in a standard scenario does not operate on shared memory, they have no global view of a single variable that can be used for synchronization. Therefore, you have to implement locks by means of message passing.
If you want to lock shared resources, you can have a central "master" regulate access to that resource.
Edit: If what you need is not sharing resources (e.g. a barrier), you can use for example MSMQ to pass messages between the machines. Probably sockets are too low level.