What is the concept of a thread in Java, and how is it used in programming?

I need to know that how java is different from other programming language can someone tell me ?

1 Answer
  1. A thread is an independent path of execution within a program.
  2. Many threads can run concurrently within a program.
  3. Every thread in Java is created and controlled by the java.lang.Thread class.
  4. A Java program can have many threads, and these threads can run concurrently, either asynchronously or synchronously.
  5. Thread is a lightweight sub process. It is a separate path of execution.
  6. Threads are independent, if there occurs exception in one thread, it doesn't affect other threads. It shares a common memory area.
  7. 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.

We use cookies to enhance your experience, to provide social media features and to analyse our traffic. By continuing to browse, you agree to our Privacy Policy.