熟悉Looper源码的朋友可能知道,looper与线程绑定并不是直接set进去的,而是通过ThreadLocal这个东西间接将looper的引用交给当前线程持有的。
Looper.java
private static void prepare(boolean quitAllowed) {
if (sThreadLocal.get() != null) {
...
分类:
其他好文 时间:
2015-04-05 09:10:04
阅读次数:
127
业务逻辑: 当有电话打进来或电话打出去的时候,对电话进行录音。public class TelphoneyListenerService extends Service { private static final String TAG = "TelphoneyListenerService...
分类:
其他好文 时间:
2015-04-04 22:33:20
阅读次数:
163
@Autowired?
?private?UserInfoService?service;?
?private?static?UserInfoService?service;
分类:
编程语言 时间:
2015-04-04 18:34:44
阅读次数:
202
单例算是最简单的设计模式了,用途自不用多说,但是写好单例也是比较考验一个程序猿功底的,这就是为什么很多面试官乐于让面试者写一写单例的原因,正所谓简约而不简单。废话不多说,下面就用java来实现各种各样的单例吧。
1.饿汉模式public class Singleton{
private static Singleton instance = new Singleton();
private...
分类:
编程语言 时间:
2015-04-04 18:25:02
阅读次数:
140
private static final int MIN_CAPACITY_INCREMENT = 12;
ArrayList每次增量为12,大小以0开始(初始化且无内容时),之后每次递增12。
构造方法:
public ArrayList(int capacity) {
if (capacity < 0) {
throw new IllegalArg...
分类:
编程语言 时间:
2015-04-03 15:29:22
阅读次数:
218
#include
#include
#include
#include
using namespace std;
class MemPool{
struct FreeNode{
struct FreeNode* next;
};
private:
static const int allocNum = 8;
static const int step = 4;
stati...
分类:
其他好文 时间:
2015-04-03 00:16:40
阅读次数:
224
Java常量定义
/**
* char 类型常量
*/
private static final char CHAR = 'A';
/**
* byte 类型常量
*/
private static final byte BYTE = 1;
/**
* short 类型常量
*/
private static final sho...
分类:
编程语言 时间:
2015-04-02 22:39:13
阅读次数:
214
方法1:
import java.util.Locale;
private static String getSuffix(File file) {
if (file == null || !file.exists() || file.isDirectory()) {
return null;
}
...
分类:
移动开发 时间:
2015-04-02 16:32:29
阅读次数:
251
一个简单的使用遍历的方式进行DataTable 的拆分 private static List DataTableSplite(DataTable dt, int modcounts) { List list = new List(); in...
public class SingleTon { private static SingleTon singleTon = null; public SingleTon() { // TODO Auto-generated constructor stub } ...
分类:
其他好文 时间:
2015-04-01 19:38:11
阅读次数:
201