일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- unix
- Audacity
- adb
- 작성중
- 코스피
- Algorithm
- Eclipse
- KOSPI
- UX
- 우분투
- 주식
- 알고리즘
- uml example
- 태터수정
- 안드로이드
- ubuntu
- Linux
- 기술사
- 공매도
- java
- IT 키워드
- IPTV
- Qmail
- 보안
- conemu
- 도서
- Android
- LDAP
- eclipse35
Archives
- Today
- Total
Do diffence
Softreference<> 를 이용한 singletone 구현 본문
com.android.contacts.model.Sources.java 에 구현한 예제
private static SoftReference<Sources> sInstance = null;
/**
* Requests the singleton instance of {@link Sources} with data bound from
* the available authenticators. This method blocks until its interaction
* with {@link AccountManager} is finished, so don't call from a UI thread.
*/
public static synchronized Sources getInstance(Context context) {
Sources sources = sInstance == null ? null : sInstance.get();
if (sources == null) {
sources = new Sources(context);
sInstance = new SoftReference<Sources>(sources);
}
return sources;
}
/**
* Requests the singleton instance of {@link Sources} with data bound from
* the available authenticators. This method blocks until its interaction
* with {@link AccountManager} is finished, so don't call from a UI thread.
*/
public static synchronized Sources getInstance(Context context) {
Sources sources = sInstance == null ? null : sInstance.get();
if (sources == null) {
sources = new Sources(context);
sInstance = new SoftReference<Sources>(sources);
}
return sources;
}