「Example17.5」の編集履歴(バックアップ)一覧はこちら
Example17.5 - (2011/02/24 (木) 09:13:50) の1つ前との変更点
追加された行は緑色になります。
削除された行は赤色になります。
#co(){
17.5 Semaphores
A common mechanism for process synchronization is a lock (or: semaphore). A lock offers two atomic actions: acquire and release. Here's the implementation of a lock in Scala:
}
** 17.5 セマフォ
プロセス同期の一般的なメカニズムは&bold(){ロック} (あるいは&bold(){セマフォ}) です。ロックは2つのアトミックなアクションを提供します。すなわち、&bold(){獲得}と&bold(){解放}です。次は Scala におけるロックの実装です。
package scala.concurrent
class Lock {
var available = true
def acquire = synchronized {
while (!available) wait()
available = false
}
def release = synchronized {
available = true
notify()
}
}
#center(){[[前ページ>Example17.4]] [[ 17 章>Chapter 17 Abstractions for Concurrency]] [[目次>ScalaByExample和訳]] [[次ページ>Example17.6]]}
----
#comment
#co(){
17.5 Semaphores
A common mechanism for process synchronization is a lock (or: semaphore). A lock offers two atomic actions: acquire and release. Here's the implementation of a lock in Scala:
}
#setmenu2(ex-r-menu)
** 17.5 セマフォ
プロセス同期の一般的なメカニズムは&bold(){ロック} (あるいは&bold(){セマフォ}) です。ロックは2つのアトミックなアクションを提供します。すなわち、&bold(){獲得}と&bold(){解放}です。次は Scala におけるロックの実装です。
package scala.concurrent
class Lock {
var available = true
def acquire = synchronized {
while (!available) wait()
available = false
}
def release = synchronized {
available = true
notify()
}
}
#center(){[[前ページ>Example17.4]] [[ 17 章>Chapter 17 Abstractions for Concurrency]] [[目次>ScalaByExample和訳]] [[次ページ>Example17.6]]}
----
#comment