Click here to Skip to main content
15,887,394 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
5 Threads all want to open an document need async/await implementation

Thread1----> trying Opening a doc1
Thread2----> trying Opening a doc1
Thread3----> trying Opening a doc1
Thread4----> trying Opening a doc1
Threadn----> trying Opening a doc1
Posted
Updated 10-Feb-15 22:40pm
v2
Comments
Richard MacCutchan 11-Feb-15 4:36am    
You have been a member here long enough to know that this site does not provide code to order. Please edit your question and give a proper explanation of your problem.
Richard MacCutchan 11-Feb-15 6:29am    
I think your design needs some work.

1 solution

Hi,

When two or more threads need to access a shared resource at the same time, the system needs a synchronization mechanism to ensure that only one thread at a time uses the resource. Mutex is a synchronization primitive that grants exclusive access to the shared resource to only one thread. If a thread acquires a mutex, the second thread that wants to acquire that mutex is suspended until the first thread releases the mutex.

Please follow below link for more information.

https://msdn.microsoft.com/en-us/library/system.threading.mutex%28v=vs.110%29.aspx[^]

Thanks.!!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900