1 / 8

CPTS 483 HW#3 Possible Solutions

CPTS 483 HW#3 Possible Solutions. Presented by- Shariful Hasan Shaikot TA CPTS 483. getInstance method is not synchronized check-then-act race condition. setStop (…) function assigns values to two related volatile fields in the simulatorThread object.

kennedyj
Download Presentation

CPTS 483 HW#3 Possible Solutions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CPTS 483HW#3 Possible Solutions Presented by-SharifulHasanShaikotTA CPTS 483

  2. getInstance method is not synchronized • check-then-act race condition

  3. setStop(…) function assigns values to two related volatile fields in the simulatorThread object. • If the thread were pre‐empted between lines 221 and 222…then ??? • These member variables need to be assigned and read under a common lock.

  4. the yield() call will allow the main thread to run so that the GUI can get set before the simulation thread begins execution. • can never be guaranteed because it is running asynchronously to the SimThread. • Since it cannot be guaranteed, this is not thread‐safe.

  5. Thank you for listening

More Related