## THREADID Get Current Thread Handle

Section: FreeMat Threads

### Usage

The `threadid` function in FreeMat tells you which thread is executing the context you are in. Normally, this is thread 1, the main thread. However, if you start a new thread using `threadnew`, you will be operating in a new thread, and functions that call `threadid` from the new thread will return their handles.

### Example

From the main thread, we have

    --> threadid

    ans =
     2

But from a launched auxilliary thread, we have

    --> t_id = threadnew

    t_id =
     3

    --> id = threadcall(t_id,1000,'threadid')

    id =
     3

    --> threadfree(t_id);