ch07_Process Synchronization_answer.doc


文档分类:IT计算机 | 页数:约3页 举报非法文档有奖
1/ 3
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/ 3
文档列表 文档介绍
Chapter 7 PROCESS SYNCHRONIZATION
The first known correct software solution to the critical-section problem for two threads was developed by Dekker; it is shown in Figure . The two threads, T0 and T1, coordinate activity sharing an object of class Dekker. Show that the algorithm satisfies all three requirements for the critical-section problem.
Answer:
No answer.
In Chapter 5, we gave a multithreaded solution to the bounded-buffer problem that used message passing. The MessageQueue class is not considered thread safe, meaning that a race condition is possible when multiple threads attempt to concurrently access the queue.
Modify the MessageQueue class using Java synchronization such that it is thread-safe.
Answer:
Please refer to the supporting Web site for source code solution.
Create a BinarySemaphore class that implements a binary semaphore.
Answer:
Please refer to the supporting Web site for source code solution.
The wait() statement in all Java program examples was part of a while loop. Explain why you would always need to use a while statement when using the wait(), and why you would never use an if statement.
Answer:
This is an important issue to emphasize! Java only provides anonymous notifi- cation—you cannot notify a certain thread that a certain condition is true. When a thread is notified, it is its responsibility to re-check the

ch07_Process Synchronization_answer 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数 3
  • 收藏数 0 收藏
  • 顶次数 0
  • 上传人 中国课件站
  • 文件大小 0 KB
  • 时间2011-10-11
最近更新