## Working with threads

### Thread API

`mono_thread_attach`
Syntax
mono_thread_attach

`mono_thread_create`
Syntax
mono_thread_create

`mono_thread_current`
Syntax
mono_thread_current

`mono_thread_detach`
Syntax
mono_thread_detach

`mono_thread_exit`
Syntax
mono_thread_exit

`mono_thread_get_managed_id`
Syntax
mono_thread_get_managed_id

`mono_thread_get_name_utf8`
Syntax
mono_thread_get_name_utf8

`mono_thread_is_foreign`
Syntax
mono_thread_is_foreign

`mono_thread_manage`
Syntax
mono_thread_manage

`mono_thread_new_init`
Syntax
mono_thread_new_init

`mono_threads_get_default_stacksize`
Syntax
mono_threads_get_default_stacksize

`mono_threads_set_default_stacksize`
Syntax
mono_threads_set_default_stacksize

`mono_thread_set_manage_callback`
Syntax
mono_thread_set_manage_callback

`mono_thread_stop`
Syntax
mono_thread_stop

`mono_thread_get_main`
Syntax
mono_thread_get_main

`mono_thread_set_main`
Syntax
void mono_thread_set_main (MonoThread *thread)

Parameters

thread | thread to set as the main thread

Description

This function can be used to instruct the runtime to treat thread as the main thread, ie, the thread that would normally execute the Main() method. This basically means that at the end of thread, the runtime will wait for the existing foreground threads to quit and other such details.

### Monitors

`mono_monitor_enter`
Syntax
mono_monitor_enter

`mono_monitor_enter_v4`
Syntax
mono_monitor_enter_v4

`mono_monitor_exit`
Syntax
mono_monitor_exit

`mono_monitor_try_enter`
Syntax
mono_monitor_try_enter

### Initialization and Shutdown

`mono_thread_cleanup`
Syntax
mono_thread_cleanup

`mono_thread_detach_if_exiting`
Syntax
mono_thread_detach_if_exiting