Multithreading in Real World

Threads are lightweight sub-processes, they share the common memory space.

When we write a program, each line is executed by JVM one by one, There is always at least one thread running internally in every program and this thread is used by JVM to execute statements in the program. Like in Java “main” is the thread executing the main class.

When we create more than one thread in a program, each thread has its own path of execution and all the threads share the same memory address space, data, and code in a program, this is known as Multithreading.

Multithreading Realtime Examples:

  1. Games are very good examples of threading. You can use multiple objects in games like cars, motorbikes, animals, people, etc. All these objects are nothing but just threads that run your game application.
  2. When we insert an ATM card, it starts a thread to perform your operations.
  3. A very good example of thread-based multithreading is a word processing program that checks the spelling of words in a document while writing the document. This is possible only if each action is performed by a separate thread.


要查看或添加评论,请登录

社区洞察

其他会员也浏览了