## THREADNEW Create a New Thread

Section: FreeMat Threads

### Usage

The `threadnew` function creates a new FreeMat thread, and returns a handle to the resulting thread. The `threadnew` function takes no arguments. They general syntax for the `threadnew` function is

       handle = threadnew

Once you have a handle to a thread, you can start the thread on a computation using the `threadstart` function. The threads returned by `threadnew` are in a dormant state (i.e., not running). Once you are finished with the thread you must call `threadfree` to free the resources associated with that thread. Some additional important information. Thread functions operate in their own context or workspace, which means that data cannot be shared between threads. The exception is `global` variables, which provide a thread-safe way for multiple threads to share data. Accesses to global variables are serialized so that they can be used to share data. Threads and FreeMat are a new feature, so there is room for improvement in the API and behavior. The best way to improve threads is to experiment with them, and send feedback.