Single vs Same vs MultiThreaded System

Spread the love

Threads can be single or multiple with each thread having it’s own thread stack.

The thread stack contains all local variables for each method being executed (all methods on the call stack). A thread can only access it’s own thread stack. The heap contains all objects created in your Java application, regardless of what thread created the object.

Single Threaded:

In a single threaded system, we only have a single thread which is running on a CPU. Since it is a single thread, it doesn’t share data. Also it utlilizes the CPU better. But modern CPU’s which have multiple processors, single threaded systems can’t make efficient use of thta since that thread would make efficient use of only one processor. That is the only drawback.

Same Threaded:

Same threaded system is a type of Multi Threaded System in which threads don’t share data. So here each thread is running on a separate CPU in parallel. So it utilizes the modern CPU’s better which are multiple core. In old CPU’s which means single CPU’s, they run alternately with CPU switching between the threads.

Multi Threaded:

In multi threaded system, multiple threads are running in parallel and they share the same data. So various aspects such as data synchronization and consistency need to be guraranteed to avoid race conditions.

Thanks for Reading!!!