您的位置:首页 > 产品设计 > UI/UE

July 7th Tuesday (七月 七日 火曜日)

2009-07-16 16:11 281 查看
Threads

Scheme supports multiple threads of evaluation. Threads run concurrently, in the sense that one thread can preempt
another without its cooperation, but threads currently all run on the same processor (i.e., the same underlying OS process
and thread).

Threads are created explicitly by functions such as thread. In terms of the evaluation model, each step in evaluation
actually consists of multiple concurrent expressions, up to one per thread, rather than a single expression. The expressions
all share the same objects and top-level variables, so that they can communicate through shared state. Most evaluation steps
involve a single step in a single expression, but certain synchronization primitives require multiple threads to progress
together in one step.

In addition to the state that is shared among all threads, each thread has its own private state that is accessed through
thread cells. A thread cell is similar to a normal mutable object, but a change to the value inside a thread cell is seen only
when extracting a value from the cell from the same thread. A thread cell can be preserved; when a new thread is created,
the creating thread's value for a preserved thread cell serves as the initial value for the cell in the created thread.
For a non-preserved thread cell, a new thread sees the same initial value (specified when the thread cell is created) as
all other threads.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: