0% found this document useful (0 votes)
13 views1 page

Threads in Java

java threads explained

Uploaded by

Anukampa Behera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Threads in Java

java threads explained

Uploaded by

Anukampa Behera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

THREADS IN JAVA

What is a thread?

- In computer science, a thread of execution is the smallest sequence of programmed instructions that
can be managed independently by a scheduler, which is typically a part of the operating system.
- It is a single sequential flow of execution of tasks of a process so it is also known as thread of
execution or thread of control.
- There can be more than one thread inside a process.
- Each thread of the same process makes use of a separate program counter and a stack of activation
records and control blocks. Thread is often referred to as a lightweight process.
- All the threads of the same process share the same CS and DS but have their own ES and SS.
- For example, in a browser, many tabs can be viewed as threads. MS Word uses many threads -
formatting text from one thread, processing input from another thread, etc.
- Two types of threads are there:
o User level: A user thread is an entity used by programmers to handle multiple flows of
controls within a program. The API for handling user threads is provided by the threads
library. A user thread only exists within a process; a user thread in process A cannot
reference a user thread in process B. The library uses a proprietary interface to handle kernel
threads for executing user threads.
o Kernel level: A kernel thread is a kernel entity, like processes and interrupt handlers; it is the
entity handled by the system scheduler. A kernel thread runs within a process, but can be
referenced by any other thread in the system. The programmer has no direct control over
these threads, unless you are writing kernel extensions or device drivers.
-

You might also like