ååãããªè¨äºãæ¸ãã¾ããã Swift ä¸ä»£ã®æä»å¶å¾¡ http://qiita.com/codelynx/items/0ecd28c8a7da0a0e42b5 ãã®è¨äºã§ã¯ã以ä¸ã®ãããªæä»å¶å¾¡ã®æ¸ãæ¹ãç´¹ä»ãã¾ãããNSLock ã使ãã°ãè¤æ°ã®ã¹ã¬ããããã¯ãªãã£ã«ã«ãªãã¼ã¿ã®åææ´æ°ãé²ããã¨ãã話ã§ãããå
·ä½çã«ã¯ãNSLock ã lock() ãã¦ãã unlock() ããã¾ã§ã¯ãä»ã®ã¹ã¬ããã¯å¾
ããããã®ã§ãatomicity ãä¿è¨¼ã§ããã¨ãã話ã§ããããããdefer æã使ãã°ãã¹ã³ã¼ããæããæã«ã確å®ã«å®è¡ãããã®ã§ãéä¸ã§ããã¤ãã® return æããããããªãã¿ã¼ã³ã§ããå®è¡ãå¿ãããªããå®å
¨ã¨ããäºã§ãã class MyObject { let lock = NSLock() func update1() { self.lock.lock() def
{{#tags}}- {{label}}
{{/tags}}