# DeleteThread

Deletes a thread.

### Synopsis

`Err DeleteThread( Item x )`

### Description

This procedure deletes a thread.

### Arguments

x
  The item number of the thread to be deleted.

### Return Value

The procedure returns a value greater than or equal to 0 if the thread was successfully deleted or an error code if an error occurs.

### Implementation

Convenience call implemented in clib.lib V20.

### Associated Files

task.h
  ANSI C Prototype

clib.lib
  ARM Link Library

### Notes

Although threads may be deleted as soon as the parent task has finished using it by calling `DeleteThread()`, threads are automatically deleted when they return, call `exit(),` or when their parent task is deleted or dies.

Threads share memory with their parent tasks. This means that:

- Memory that was allocated by a thread also belongs to the parent task.
- Memory that was allocated by a thread is not automatically deallocated when the thread is deleted but instead remains the property of the parent task.

If you create a thread using `CreateThread()`, you must delete it using `DeleteThread()`, which does special cleanup work.

### See Also

``CreateThread`(), exit()`

#