Just a little smile ^ ^

yoyo_zeng

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2012年11月13日

摘要: 依赖注入,由传统的 has a,改为在配置文件中注入,降低依赖。传统方式:依赖性大public class A{private B data1;.....}public class B{...}注入public class A{private BParent data1;public A(){...}public A(int i, B b){...}.....}public interface BParent{...}public class B implements BParent{...}<beans><bean id="A" class =" 阅读全文
posted @ 2012-11-13 17:59 yoyo_zeng 阅读(1360) 评论(0) 推荐(0)

摘要: Using a POSIX Mutex Lockc语言方法pthread_mutex_t mutex;void MyInitFunction(){ pthread_mutex_init(&mutex, NULL);} void MyLockingFunction(){ pthread_mutex_lock(&mutex); // Do work. pthread_mutex_unlock(&mutex);}Using the NSLock ClassBOOL moreToDo = YES;NSLock *theLock = [[NSLock alloc] init];. 阅读全文
posted @ 2012-11-13 10:32 yoyo_zeng 阅读(334) 评论(0) 推荐(0)

摘要: 如果你在非main thread中运行run loop,你必须至少为该run loop添加一个input sources或timer。如果你运行的run loop没有监控任何的输入源,该run loop将在你运行后立即退出。Run loop observer使用detachNewThreadSelector:toTarget:withObject:创建一个thread:[cpp]view plaincopy[NSThreaddetachNewThreadSelector:@selector(observerRunLoop)toTarget:selfwithObject:nil];在新threa 阅读全文
posted @ 2012-11-13 09:40 yoyo_zeng 阅读(329) 评论(0) 推荐(0)