Question: I have the following code which initiate the thread.

```
int iNMHandleThread = 1;
HANDLE hNMHandle = 0;
hNMHandle = CreateThread( NULL, 0, NMHandle, &iNMHandleThread, 0, NULL);
if ( hNMHandle == NULL)
ExitProcess(iNMHandleThread);

```

My question is

1. What will happened if I run this code while the thread already in the running state.
2. I want to initiate the multiple independent threads of NMHandle kindly give me some hints to solve this problem.

Answer: 
Each time you call `CreateThread`, a new thread is started that is independent of any other currently-running threads. Whether your "NMHandle" function is capable of running on more than one thread at a time is up to you: for example, does it rely on any global state?
> 
> What will happened if I run this code while the thread already in the running state.
> 
> 
> 

Another thread will start with the function `NMHandle`, independent of the other one.

> 
> I want to initiate the multiple independent threads of NMHandle kindly give me some hints to solve this problem.
> 
> 
> 

This code actually creates an independent thread. Create a loop if you want to create multiple threads executing the function `NMHandle`. If you need the thread handles later (e.g. waiting for a thread to end), you have to store them somewhere.

Make sure that `NMHandle` is thread-safe. If you don't know what that means, you shouldn't start multithreaded programming yet!

And another hint: You're passing a pointer to the local stack variable `iNMHandleThread` to the thread. As soon as the function returns, the variable content might not have its expected value anymore - you should rather pass the number by value (`CreateThread( NULL, 0, NMHandle, (void*)iNMHandleThread, 0, NULL);`).