今天读MediaProvoider的源码的时候,读到一下代码:
public class MediaScannerService extends Service implements Runnable{
......
public void run()
{
// reduce priority below other background threads to avoid interfering
// with other services at boot time.
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND +
Process.THREAD_PRIORITY_LESS_FAVORABLE);
Looper.prepare(); mServiceLooper = Looper.myLooper();
mServiceHandler = new ServiceHandler(); Looper.loop();
}
......
}
由此,我是否可以认为Android的消息系统和Windows系统有一点相同的地方:非UI线程在建立的时候,并没有消息泵。只有通过在非UI线程中调用与消息泵有关的代码时,系统才为非UI线程建立消息泵?
public class MediaScannerService extends Service implements Runnable{
......
public void run()
{
// reduce priority below other background threads to avoid interfering
// with other services at boot time.
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND +
Process.THREAD_PRIORITY_LESS_FAVORABLE);
Looper.prepare(); mServiceLooper = Looper.myLooper();
mServiceHandler = new ServiceHandler(); Looper.loop();
}
......
}
由此,我是否可以认为Android的消息系统和Windows系统有一点相同的地方:非UI线程在建立的时候,并没有消息泵。只有通过在非UI线程中调用与消息泵有关的代码时,系统才为非UI线程建立消息泵?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货