Multi-threaded applications may need to coordinate threads that share data or other resources. Different processes may need to coordinate with each other as well.

The sequence matters, in order to guarantee the results’ correctness. And meanwhile we definitely want to improve the performance.

So what are the common approaches for this? And what are the pros and cons?



Similar Posts:


linkedin
github
slack

Name Summary
Dead Lock  
Atomic Operations  
Lock & Metasphore  
Lock-free  
Async Programming  
Race Conditions  
Implement Thread-safe queue/hashmap  

Q: Concurrency between multiple threads?

A: TODO


Q: Multiprocessing vs Multithreading?

A: TODO


Q: Multiprocessing vs Multithreading?

A: TODO


Q: How to detect dead lock and prevent it?

A: TODO


Q: Synchronous vs. Asynchronous

With async architectures, we can scale out for better performance.

But with sync architectures, the performance may not improve, even if we are willing to add more infrastures.

e.g, performance bottlenecks are at applications, instead of Databases. And the application has lots of locks and even starvations.


Q: Synchronized in Java. How it’s implemented?

Multi-threaded programs may often come to a situation where multiple threads try to access the same resources and finally produce erroneous and unforeseen results.

// Only one thread can execute at a time. 
// sync_object is a reference to an object
// whose lock associates with the monitor. 
// The code is said to be synchronized on
// the monitor object
synchronized(sync_object)
{
   // Access shared variables and other
   // shared resources
}

link



Share It, If You Like It.

Leave a Reply

Your email address will not be published. Required fields are marked *