ãµã¨æ°ã«ãªã£ãã®ã§å®é¨ãã¦ã¿ãã Objective-Cã®@synchronizedã¯ãã¤ã¾ãã¯mutexãããã Appleã®ããã¥ã¡ã³ãã«æ¸ãã¦ãã£ãã ä¾ãã°ã @implementation Singleton @synthesize count; static Singleton* singleton = nil; + (id)sharedObject{ if (!singleton) { singleton = [[Singleton alloc]init]; singleton.count = 0; } return singleton; } - (void)increment{ count ++; NSLog(@"%d",count); } @end ãããªæãã§ã·ã³ã°ã«ãã³ãªãªãã¸ã§ã¯ããç¨æãã¦ãincrementãGCD使ã£ã¦10ä¸åå¼ãã§ã¿ãã Singleton
{{#tags}}- {{label}}
{{/tags}}