일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- Linux
- 보안
- 코스피
- Algorithm
- IT 키워드
- 우분투
- Qmail
- conemu
- ubuntu
- eclipse35
- LDAP
- 작성중
- Eclipse
- KOSPI
- 태터수정
- Audacity
- 기술사
- UX
- 공매도
- 알고리즘
- unix
- Android
- uml example
- 안드로이드
- IPTV
- java
- 도서
- 주식
- adb
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;
}