《设计模式-11-同步型设计模式》由会员分享,可在线阅读,更多相关《设计模式-11-同步型设计模式(6页珍藏版)》请在金锄头文库上搜索。
1、同步型设计模式同步型设计模式同步型设计模式同步型设计模式常见同步型设计模式Scoped Lock设计模式Strategized Locking设计模式Thread-Safe Interface 设计模式Double-Checked Locking Optimization设计模式Scoped Lock设计模式设计模式The Scoped Locking C+ idiom ensures that a lock is acquired when control enters a scopeand released automatically when control leaves the sco
2、pe, regardless of the return path fromthe scope.Strategized Locking设计模式设计模式The Strategized Locking design pattern parameterizes synchronization mechanisms thatprotect a components critical sections from concurrent access.Thread-Safe InterfaceThe Thread-Safe Interface design pattern minimizes locking
3、 overhead and ensures thatintra-component method calls do not incur self-deadlock by trying to reacquire a lock that isheld by the component already.Double-Checked Locking OptimizationThe Double-Checked Locking Optimization design pattern reduces contention andsynchronization overhead whenever critical sections of code must acquire locks in a threadsafemanner just once during program execution.