Posts

Showing posts with the label thread methods

Java Multithreading जावा में मल्टीथ्रेडिंग

Multithreading in Java is a powerful feature that allows concurrent execution of two or more parts of a program to make the best use of CPU. Java enables programs to perform multiple tasks simultaneously using threads. जब हम जावा प्रोग्राम चलाते हैं, तो CPU को कई बार इंतजार करना पड़ता है जैसे – इनपुट लेने में, नेटवर्क रिस्पॉन्स का इंतजार, या कोई अन्य प्रोसेस के कारण। इस बेकार समय का उपयोग हम दूसरे कार्यों के लिए कर सकते हैं, और यही प्रक्रिया Multithreading कहलाती है। 🧵 What is a Thread? (थ्रेड क्या होता है?) A Thread is a lightweight subprocess, the smallest unit of processing. A thread executes within a program and shares process resources with other threads. एक थ्रेड वह यूनिट है जो "execution में चल रहा प्रोग्राम" कहलाता है। जावा प्रोग्राम में default thread main() होता है। लेकिन हम और भी थ्रेड्स बना सकते हैं ताकि काम समानांतर (parallel) हो सके। 🔄 Thread Life Cycle (थ्रेड का जीवन चक्र) New – Thread is created. थ्रेड ऑब्जेक्ट बनते ही इस स्थिति में होता है। ...