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