Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between handle and thread?

Tags:

.net

windows

I see in Windows Task Manager -> Performance tab under system block, I see Process, threads and handle statistics.

Can some body tell me what are handles(with technical information including development point of view)?

like image 629
Jai Mallesh Babu Avatar asked Sep 14 '12 11:09

Jai Mallesh Babu


People also ask

What are thread handles?

Thread handle is used by the operating system that identifies processes and threads, users can use the handle to identify processes and threads and operate on them. The thread ID is used by the operating system to identify processes and threads.

What are handles on a CPU?

In computer programming, a handle is an abstract reference to a resource that is used when application software references blocks of memory or objects that are managed by another system like a database or an operating system.

What is handle in process?

A process handle is an integer value that identifies a process to Windows. The Win32 API calls them a HANDLE; handles to windows are called HWND and handles to modules HMODULE. Threads inside processes have a thread handle, and files and other resources (such as registry keys) have handles also.

What does threads mean in Task Manager?

A thread is the basic unit to which the operating system allocates processor time. A thread can execute any part of the process code, including parts currently being executed by another thread. A job object allows groups of processes to be managed as a unit.


1 Answers

A thread is part of the process, running within its own execution space and there can be multiple threads in one process. with the help of it os can do multiple tasks in parallel(depends upon the number of processors of the machine.

A handle is a generic OS term that can be a ticket to an operating system object. Each handle is unique and identifies each object. A thread is an OS object and each one you create, you get back a handle for it.

Under Windows, the thread handle is different from the thread ID, in the same way that a file handle is different from a file name.

The thread handle is a token which allows you to do something with the thread (typically wait for it or kill it). Win32 has these tokens for lots of objects, and calls them HANDLE in general.

like image 173
Raja Fawad Avatar answered Sep 17 '22 15:09

Raja Fawad