Threads DataType

There are two types of threads in type-c language, threads that are spawned using an expression, and thread that are spawned using a custom thread type.

Case 1: Spawning an expression

Spawning an expression creates a new thread that runs concurrently with the current thread. The returned type however is not thread, but a promise that can be awaited. Once the thread is finished, the promise is resolved with the return value of the thread.

Case 2: Spawning an interactive thread

thread<T> type represents a thread that can be spawned and run concurrently. This is different from regular threads that return a promoise, since these threads support communication between them.

threads are very similar to classes, in the sense that they can have their own states. But they are not to be confused with classes! They are very different entities. Additionally, threads cannot be casted to any other types (even themselves, similar to classes in this aspect).


Kudos! Keep reading!