当前位置: 首页 > news >正文

域名对网站有什么影响吗深圳有多少家企业

域名对网站有什么影响吗,深圳有多少家企业,网站管理员登陆不了,软件开发和网站开发的区别Android一个APP里面最少有几个线程 参考 https://www.jianshu.com/p/92bff8d6282f https://www.jianshu.com/p/8a820d93c6aa 线程查看 Android一个进程里面最少包含5个线程,分别为: main线程(主线程)FinalizerDaemon线程 终结者守护线程…

Android一个APP里面最少有几个线程

参考

https://www.jianshu.com/p/92bff8d6282f
https://www.jianshu.com/p/8a820d93c6aa

线程查看

Android一个进程里面最少包含5个线程,分别为:

  1. main线程(主线程)
  2. FinalizerDaemon线程
    终结者守护线程。对于重写了成员函数finalize的对象,它们被GC决定回收时,并没有马上被回收,而是被放入到一个队列中,等待FinalizerDaemon守护线程去调用它们的成员函数finalize,然后再被回收。
  3. FinalizerWatchdogDaemon线程
    监控终结者守护线程。用来监控FinalizerDaemon线程的执行。一旦检测那些重定了成员函数finalize的对象在执行成员函数finalize时超出一定的时候,那么就会退出VM。
  4. HeapTaskDaemon线程
    堆栈守护线程。用来执行堆栈的操作,也就是用来将那些空闲的堆内存归还给系统。
  5. ReferenceQueueDaemon线程。
    引用队列守护线程。我们知道,在创建引用对象的时候,可以关联一个队列。当被引用对象引用的对象被GC回收的时候,被引用对象就会被加入到其创建时关联的队列去。这个加入队列的操作就是由ReferenceQueueDaemon守护线程来完成的。这样应用程序就可以知道哪些被引用对象引用的对象已经被回收了。

下图是创建的一个仅有hello World!页面的工程,线程包含以下的这些。

在这里插入图片描述

刚开始我比较疑惑的是FileObserver 这个线程是否也是每个进程所必须包含的线程。后来我查看了一下Daemons创建的过程,能确定的是Android启动一个APP最少包含ReferenceQueueDaemon线程、FinalizerDaemon线程、FinalizerWatchdogDaemon线程、HeapTaskDaemon线程,以及在ActivityThread中开启的主线程。如下:

public final class Daemons {private static final int NANOS_PER_MILLI = 1000 * 1000;private static final int NANOS_PER_SECOND = NANOS_PER_MILLI * 1000;private static final long MAX_FINALIZE_NANOS = 10L * NANOS_PER_SECOND;public static void start() {ReferenceQueueDaemon.INSTANCE.start();//开启ReferenceQueueDaemon线程FinalizerDaemon.INSTANCE.start();//开启FinalizerDaemon线程FinalizerWatchdogDaemon.INSTANCE.start();//开启FinalizerWatchdogDaemon线程HeapTaskDaemon.INSTANCE.start();//开启HeapTaskDaemon线程}public static void startPostZygoteFork() {ReferenceQueueDaemon.INSTANCE.startPostZygoteFork();FinalizerDaemon.INSTANCE.startPostZygoteFork();FinalizerWatchdogDaemon.INSTANCE.startPostZygoteFork();HeapTaskDaemon.INSTANCE.startPostZygoteFork();}public static void stop() {HeapTaskDaemon.INSTANCE.stop();ReferenceQueueDaemon.INSTANCE.stop();FinalizerDaemon.INSTANCE.stop();FinalizerWatchdogDaemon.INSTANCE.stop();}...
}

1.main线程

2. ReferenceQueueDaemon线程。

代码块

3. FinalizerDaemon线程

    private static class FinalizerDaemon extends Daemon {private static final FinalizerDaemon INSTANCE = new FinalizerDaemon();private final ReferenceQueue<Object> queue = FinalizerReference.queue;private final AtomicInteger progressCounter = new AtomicInteger(0);// Object (not reference!) being finalized. Accesses may race!private Object finalizingObject = null;FinalizerDaemon() {super("FinalizerDaemon");}@Override public void runInternal() {// This loop may be performance critical, since we need to keep up with mutator// generation of finalizable objects.// We minimize the amount of work we do per finalizable object. For example, we avoid// reading the current time here, since that involves a kernel call per object.  We// limit fast path communication with FinalizerWatchDogDaemon to what's unavoidable: A// non-volatile store to communicate the current finalizable object, e.g. for// reporting, and a release store (lazySet) to a counter.// We do stop the  FinalizerWatchDogDaemon if we have nothing to do for a// potentially extended period.  This prevents the device from waking up regularly// during idle times.// Local copy of progressCounter; saves a fence per increment on ARM and MIPS.int localProgressCounter = progressCounter.get();while (isRunning()) {try {// Use non-blocking poll to avoid FinalizerWatchdogDaemon communication// when busy.FinalizerReference<?> finalizingReference = (FinalizerReference<?>)queue.poll();if (finalizingReference != null) {finalizingObject = finalizingReference.get();progressCounter.lazySet(++localProgressCounter);} else {finalizingObject = null;progressCounter.lazySet(++localProgressCounter);// Slow path; block.FinalizerWatchdogDaemon.INSTANCE.goToSleep();finalizingReference = (FinalizerReference<?>)queue.remove();finalizingObject = finalizingReference.get();progressCounter.set(++localProgressCounter);FinalizerWatchdogDaemon.INSTANCE.wakeUp();}doFinalize(finalizingReference);} catch (InterruptedException ignored) {} catch (OutOfMemoryError ignored) {}}}@FindBugsSuppressWarnings("FI_EXPLICIT_INVOCATION")private void doFinalize(FinalizerReference<?> reference) {FinalizerReference.remove(reference);Object object = reference.get();reference.clear();try {object.finalize();} catch (Throwable ex) {// The RI silently swallows these, but Android has always logged.System.logE("Uncaught exception thrown by finalizer", ex);} finally {// Done finalizing, stop holding the object as live.finalizingObject = null;}}}

4. FinalizerWatchdogDaemon线程

代码块

5. HeapTaskDaemon线程

private static class HeapTaskDaemon extends Daemon {private static final HeapTaskDaemon INSTANCE = new HeapTaskDaemon();HeapTaskDaemon() {super("HeapTaskDaemon");}// Overrides the Daemon.interupt method which is called from Daemons.stop.public synchronized void interrupt(Thread thread) {VMRuntime.getRuntime().stopHeapTaskProcessor();}@Override public void runInternal() {synchronized (this) {if (isRunning()) {// Needs to be synchronized or else we there is a race condition where we start// the thread, call stopHeapTaskProcessor before we start the heap task// processor, resulting in a deadlock since startHeapTaskProcessor restarts it// while the other thread is waiting in Daemons.stop().VMRuntime.getRuntime().startHeapTaskProcessor();}}// This runs tasks until we are stopped and there is no more pending task.VMRuntime.getRuntime().runHeapTasks();}}

查看VMRuntime的源码发现 startHeapTaskProcessor()、runHeapTasks()均是native方法。

    public native void requestConcurrentGC();public native void concurrentGC();public native void requestHeapTrim();public native void trimHeap();public native void startHeapTaskProcessor();public native void stopHeapTaskProcessor();public native void runHeapTasks();

如何查看当前项目包含几个线程

在Android studio中点击Profile 图标,点击 CPU,显示如下图,点击 Record,然后再点击 Stop,即可生成。

http://www.hyszgw.com/news/62434.html

相关文章:

  • 自己做h5网站wordpress页面显示返回json
  • ui网站建设搭建平台 提供舞台
  • 阿里云个人网站制作外贸网站网站推广
  • 什么网站会更有浏览量免费源码资源
  • 山西省建设厅网站见证员证书宋来增网站运维公司
  • 网站内容建设情况网站策划专员招聘
  • 聊城网站建设报价企业邮箱怎么看
  • 太原网站建设的公司北京和隆优化科技
  • 网站制作小图标网站做导航设计的作用是什么意思
  • h5网站制作工具山东省建设厅网站 - 百度
  • 做星座网站网站建设运营要求
  • 做网站的可以注册个工作室吗在线制作图片软件
  • 张家港保税区建设规划局网站企业网站模块种类
  • 浏览器编程语言北京seo全网营销
  • 做网批那个网站好视频模板在线制作网站
  • ps怎么做网站logo网站图片水印
  • 张家界网站建设方案特别好的企业网站程序
  • 做优化网站注意什么如何搭wordpress
  • 金山网站建设网站开发精品课程
  • 湖州南浔建设局网站微信短网址生成
  • wordpress网站怎么建设长垣县住房和城乡建设局网站
  • 做微信商城网站公司网站备案域名怎么买
  • 哪里有免费的网站推广软件珠海网站建设服务
  • 做网站的上海市哪家技术好互联网公司排名100强湖
  • 做动态图片下载哪个网站好商城的网站建设
  • 即墨网站开发公司软件设计培训
  • 电商网站开发经验免费seo搜索优化
  • 做阿里云网站的公司网站开发运行环境怎么写
  • 如何免费建立一个自己的网站资讯cms网站有那些
  • 开发购物网站社交的软件公司wordpress easycode