MULTITHREADING

  • process of executing multiple threads simultaneously.
  • Thread is basically a light weight sub-process , a smallest unit of processing. Multiprocessing and multi threading , both are used to achieve multiprocessing.
  • threads share a common memory, and context switching between threads takes less time than process.
  • Java multi threading mostly used in games and animation etc.
  • Advantages:
 1.It doesn't block the user because threads are independent and you can perform multiple operators at same time
2. you can peform many operations together to save time
3. Threads are independent it doesn't effect other threads if exception occur in single thread.

  • Multi tasking:
process of executing multiple tasks simultaniously . we use multitasking to utilize the CPU. we can achieve by two ways
   1. process based multitasking(multiprocessing)
  2. thread based multitasking(multithreading)
1.process based multitasking:
  • Each process have its own address in memory i.e. each process allocates separate memory area.
  • Process is heavyweight.
  • Cost of communication between the process is high.
  • Switching from one process to another require some time for saving and loading registers, memory maps, updating lists etc.
2.thread based multitasking:
  • Each process have its own address in memory i.e. each process allocates separate memory area.
  • Process is heavyweight.
  • Cost of communication between the process is high.
  • Switching from one process to another require some time for saving and loading registers, memory maps, updating lists etc.
  • At least one process is required for each thread.

  • Thread in JAVA:
Thread is a light weight sub process a smallest unit of processing. It is a separate path of execution.
Threads are independent , if there occurs exception in one thread , it doesn't effect other threads. it shares a common memory area.
what is thread in java
As shown in the above figure, thread is executed inside the process. There is context-switching between the threads. There can be multiple processes inside the OS and one process can have multiple threads.
at a time only one thread executes.

Comments

Popular posts from this blog

Database Definition and DBMS