Handler 消息队列中的同步屏障——Message

news2025/7/7 2:29:44

Message 分为3种:普通消息(同步消息)、屏障消息(同步屏障)和异步消息。我们通常使用的都是普通消息,而屏障消息就是在消息队列中插入一个屏障,在屏障之后的所有普通消息都会被挡着,不能被处理。不过异步消息却例外,屏障不会挡住异步消息

因此可以这样认为:屏障消息就是为了确保异步消息的优先级,设置了屏障后,只能处理其后的异步消息,同步消息会被挡住,除非撤销屏障。

那什么是同步屏障机制呢?

同步屏障机制是一套为了让某些特殊的消息得以更快被执行的机制

  • 注意这里我在同步屏障之后加上了机制二字,原因是单纯的同步屏障并不起作用,他需要和其他的Handler组件配合才能发挥作用。
  • 这里我们假设一个场景:我们向主线程发送了一个UI绘制操作Message,而此时消息队列中的消息非常多,那么这个Message的处理可能会得到延迟,绘制不及时造成界面卡顿。同步屏障机制的作用,是让这个绘制消息得以越过其他的消息,优先被执行。
  • MessageQueue中的Message,有一个变量isAsynchronous,他标志了这个Message是否是异步消息;标记为true称为异步消息,标记为false称为同步消息。同时还有另一个变量target,标志了这个Message最终由哪个Handler处理。

那么这些同步消息什么时候可以被处理呢?

那就需要先移除这个同步屏障,即调用 removeSyncBarrier()

我们的手机屏幕刷新频率有不同的类型,60Hz、120Hz 等。60Hz 表示屏幕在一秒内刷新 60 次,也就是每隔 16.6ms 刷新一次

  • 屏幕会在每次刷新的时候发出一个 VSYNC 信号,通知 CPU 进行绘制计算。
  • 具体到我们的代码中,可以认为就是执行 onMesure()、onLayout()、onDraw() 这些方法。好了,大概了解这么多就可以了。

了解过 view 绘制原理的读者应该知道,view 绘制的起点是在 viewRootImpl.requestLayout() 方法开始,这个方法会去执行上面的三大绘制任务,就是测量布局绘制;但是,重点来了:

调用 requestLayout() 方法之后,并不会马上开始进行绘制任务,而是会给主线程设置一个同步屏障,并设置 ASYNC 信号监听;当 ASYNC 信号的到来,会发送一个异步消息到主线程 Handler,执行我们上一步设置的绘制监听任务,并移除同步屏障

这里我们只需要明确一个情况: 调用 requestLayout() 方法之后会设置一个同步屏障,知道 ASYNC 信号到来才会执行绘制任务并移除同步屏障

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java" cid="n99" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java" cid="n208" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">api29
 @Override
 public void requestLayout() {
 if (!mHandlingLayoutInLayoutRequest) {
 checkThread();
 mLayoutRequested = true;
 scheduleTraversals();//发送同步屏障
 }
 }</pre></pre>

那,这样在等待 ASYNC 信号的时候主线程什么事都没干?

是的;这样的好处是:

保证在 ASYNC 信号到来之时,绘制任务可以被及时执行,不会造成界面卡顿。但这样也带来了相对应的代价:

  • 我们的同步消息最多可能被延迟一帧的时间,也就是 16ms,才会被执行
  • 主线程 Looper 造成过大的压力,在 VSYNC 信号到来之时,才集中处理所有消息
改善这个问题办法就是:使用异步消息

当我们发送异步消息到 MessageQueue 中时,在等待 VSYNC 期间也可以执行我们的任务,让我们设置的任务可以更快得被执行且减少主线程 Looper 的压力

异步消息机制本身就是为了避免界面卡顿,那我们直接使用异步消息,会不会有隐患?

这里我们需要思考一下,什么情况的异步消息会造成界面卡顿: 异步消息任务执行过长、异步消息海量

  • 如果异步消息执行时间太长,那即时是同步任务,也会造成界面卡顿,这点应该都很好理解
  • 其次,若异步消息海量到达影响界面绘制,那么即使是同步任务,也是会导致界面卡顿的
  • 原因是 MessageQueue 是一个链表结构,海量的消息会导致遍历速度下降,也会影响异步消息的执行效率。

所以我们应该注意的一点是:

不可在主线程执行重量级任务,无论异步还是同步

那,我们以后岂不是可以直接使用异步 Handler 来取代同步 Handler 了?是,也不是

  • 同步 Handler 有一个特点是会遵循与绘制任务的顺序,设置同步屏障之后,会等待绘制任务完成,才会执行同步任务;
  • 而异步任务与绘制任务的先后顺序无法保证,在等待 VSYNC 的期间可能被执行,也有可能在绘制完成之后执行。
  • 建议是:如果需要保证与绘制任务的顺序,使用同步 Handler;其他,使用异步 Handler

在 Android 系统里面为了更快响应UI刷新在 ViewRootImpl.scheduleTraversals 也有应用:

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java" cid="n130" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java" cid="n228" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;"> android.view.ViewRootImpl#scheduleTraversals
 void scheduleTraversals() {
 if (!mTraversalScheduled) {
 mTraversalScheduled = true;
 //开启同步屏障
 mTraversalBarrier = mHandler.getLooper().getQueue().postSyncBarrier();
 //发送异步消息
 mChoreographer.postCallback(
 Choreographer.CALLBACK_TRAVERSAL, mTraversalRunnable, null);
 if (!mUnbufferedInputDispatch) {
 scheduleConsumeBatchedInput();
 }
 notifyRendererOfFramePending();
 pokeDrawLockIfNeeded();
 }
 }</pre></pre>

postCallback() 最终走到了 ChoreographerpostCallbackDelayedInternal():

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java" cid="n132" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java" cid="n230" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;"> 最后调用 android.os.MessageQueue#enqueueMessage
 boolean enqueueMessage(Message msg, long when) {}</pre></pre>

同步屏障是通过 MessageQueue的postSyncBarrier 方法插入到消息队列的

  • MessageQueue 中的 Message,有一个变量 isAsynchronous,他标志了这个 Message 是否是异步消息;标记为 true 称为异步消息,标记为 false 称为同步消息
  • 同时还有另一个变量 target,标志了这个 Message 最终由哪个 Handler 处理

MessageQueue #postSyncBarrier 方法的源码如下:

重点在于: 没有给 Message 赋值 target 属性,且插入到 Message 队列头部 这个 target==null 的特殊 Message 就是同步屏障

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java" cid="n142" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java" cid="n235" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">android.os.MessageQueue#postSyncBarrier()
public int postSyncBarrier() {
 return postSyncBarrier(SystemClock.uptimeMillis());
}
private int postSyncBarrier(long when) {
//将新的同步屏障令牌排队。
//我们不需要叫醒排队的人,因为设置障碍物的目的是让他们停下来。
 // Enqueue a new sync barrier token.
 // We don't need to wake the queue because the purpose of a barrier is to stall it.
 synchronized (this) {
 final int token = mNextBarrierToken++;
 //1、屏障消息和普通消息的区别是屏障消息没有tartget。
 final Message msg = Message.obtain();
 msg.markInUse();
 msg.when = when;
 msg.arg1 = token;

 Message prev = null;
 Message p = mMessages;
 //2、根据时间顺序将屏障插入到消息链表中适当的位置
 if (when != 0) {
 while (p != null && p.when <= when) {
 prev = p;
 p = p.next;
 }
 }
 if (prev != null) { // invariant: p == prev.next
 msg.next = p;
 prev.next = msg;
 } else {
 msg.next = p;
 mMessages = msg;
 }
 //3、返回一个序号,通过这个序号可以撤销屏障
 return token;
 }
}</pre></pre>
  • postSyncBarrier 返回一个 int 类型的数值,通过这个数值可以撤销屏障
  • postSyncBarrier方法是私有的,如果我们想调用它就得使用反射
  • 插入普通消息会唤醒消息队列,但是插入屏障不会

添加异步消息有两种办法:

  • 使用异步类型的Handler发送的全部Message都是异步的
  • 给Message标志异步.
<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java" cid="n156" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java" cid="n243" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;"> public Handler(boolean async) {
 this(null, async);
 }
 final boolean mAsynchronous;
 if (mAsynchronous) {
 msg.setAsynchronous(true);
 }</pre></pre>

异步类型的 Handler 构造器是标记为 hide,我们无法使用,但在 api28 之后添加了两个重要的方法:

  • 通过这两个 api 就可以创建异步 Handler 了,而异步 Handler 发出来的消息则全是异步的
<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java" cid="n161" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java" cid="n245" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">public static Handler createAsync(@NonNull Looper looper) {
 if (looper == null) throw new NullPointerException("looper must not be null");
 return new Handler(looper, null, true);
}


public static Handler createAsync(@NonNull Looper looper, @NonNull Callback callback) {
 if (looper == null) throw new NullPointerException("looper must not be null");
 if (callback == null) throw new NullPointerException("callback must not be null");
 return new Handler(looper, callback, true);
}

public void setAsynchronous(boolean async) {
 if (async) {
 flags |= FLAG_ASYNCHRONOUS;
 } else {
 flags &= ~FLAG_ASYNCHRONOUS;
 }</pre></pre>

总结

  • 同步屏障可以通过 MessageQueue.postSyncBarrier 函数来设置。该方法发送了一个没有 target 的 Message 到 Queue 中
  • 在 next 方法中获取消息时,如果发现没有 target 的 Message,则在一定的时间内跳过同步消息,优先执行异步消息。
  • 再换句话说,同步屏障为 Handler 消息机制增加了一种简单的优先级机制,异步消息的优先级要高于同步消息
  • 在创建 Handler 时有一个 async 参数,传 true 表示此 handler 发送的时异步消息。ViewRootImpl.scheduleTraversals 方法就使用了同步屏障,保证 UI 绘制优先执行

这篇文章,其实不难;主要是将 Android 消息屏障机制 IdelHandler (同步屏障 sync barrier,异步消息 )以及在开发当中经常用到的一些知识点,总结了一下

想要往向更深入学习难免需要寻找很多的学习资料辅助,我在这里推荐网上整合的一套 《 Android Handler 消息机制学习手册》;鉴于出自大佬之手,可以帮助到大家, 能够少走些弯路

Handler 机制之 Thread

Handler 机制之 Thread Local

Handler 机制之 Callable、Future 和 Fulure Task

篇幅原因,就不在这里为大家赘述了,有需要的小伙伴:可以私信发送 “面试” 即可领取这份 《 Android Handler 消息机制学习手册》,助你早日成为 底层原理大师!

最后大家如果觉得手册内容有用的话,可以点赞分享一下哦~

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/7032.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

隐式类型转换(整形提升)

隐式类型转换1.定义2.整形提升例子3.char的取值范围和一些技巧1.定义 1.c的整形算术运算总是至少以缺省整形类型的精度来进行的。 2.为了获取这个精度&#xff0c;像字符型&#xff0c;短整形在使用之前会转换为整形&#xff0c;这种转换被称为整形提升 3.整形提升时补最高位的…

Baklib|信息管理和知识管理是如何影响你的业务的?

有效的信息和知识管理可以让您消除库和共享知识。本文讨论了信息管理和知识管理的来龙去脉。信息管理和知识管理通常可以互换使用&#xff0c;但也有关键的区别。了解这些差异以及它们如何影响您的业务&#xff0c;可以使您优化管理策略、简化工作流程并提高生产率。 本文涵盖…

灰色GM(1,1)模型及其在电力负荷预测中的应用附Matlab代码

✅作者简介&#xff1a;热爱科研的Matlab仿真开发者&#xff0c;修心和技术同步精进&#xff0c;matlab项目合作可私信。 &#x1f34e;个人主页&#xff1a;Matlab科研工作室 &#x1f34a;个人信条&#xff1a;格物致知。 更多Matlab仿真内容点击&#x1f447; 智能优化算法 …

【每日一题】LFU 缓存

一个缓存结构需要实现如下功能&#xff1a; void set(int key,int value)&#xff1a;加入或者修改 key 对应的 value int get(int key)&#xff1a;查询 key 对应的 value 值 但是缓存最多放 K 条记录&#xff0c;如果新的 K 1 条记录需要加入&#xff0c;就需要根据策略删掉…

【面试题】如何替换项目中的if-else和switch

给大家推荐一个实用面试题库 1、前端面试题库 &#xff08;面试必备&#xff09; 推荐&#xff1a;★★★★★ 地址&#xff1a;前端面试题库 在项目中&#xff0c;往往会看到很多的if-else或者switch&#xff0c;项目会变得很臃肿&#xff0c;而且不易阅读&…

速溶颗粒:实验中的好伙伴

缓冲溶液 (buffer solution) 通常是由弱酸及其盐、弱碱及其盐组成的混合溶液&#xff0c;能在一定程度上抵消、减轻外加强酸或强碱对溶液酸碱度的影响&#xff0c;从而保持溶液的 pH 值相对稳定。 传统的缓冲液配制过程可简单概括为计算——称量——溶解——定容。而生物学上常…

windows10提权

参照tryhackme的win10提权靶场 靶场&#xff0c;地址 里面共描述了服务路径&#xff0c;文件权限&#xff0c;计划任务&#xff0c;令牌窃取&#xff0c;图形化软件&#xff0c;应用组件安装等&#xff0c;这里只有令牌窃取需要管理员Administrator权限&#xff0c;值得注意的是…

向毕业妥协系列之机器学习笔记:无监督学习-聚类

目录 序言 一.什么是聚类 二.K-means算法 三.优化目标 四.初始化K-means 五.选择聚类数量&#xff08;k?&#xff09; 序言 第三课这块要学习的几块知识如下&#xff1a; 在学完监督学习之后&#xff0c;接下来我们要学习的东西分别是聚类&#xff0c;异常检测&#xf…

Spring 源码阅读 74:事务管理的原理 - BeanFactoryTransactionAttributeSourceAdvisor 分析

本文通过对 BeanFactoryTransactionAttributeSourceAdvisor 类的分析&#xff0c;了解了 Spring 是如何通过 AOP 来完成事务的管理的&#xff0c;本文的内容需要你对 Spring 的 AOP 的实现原理有一定的了解。 基于 Spring Framework v5.2.6.RELEASE 概述 Spring 的事务管理基于…

基于 Flask-Admin 与 AdminLTE 构建通用后台管理系统

Flask-Admin 是什么&#xff1f; Flask-Admin 官网文档中给出了其功能定位&#xff1a; Why Flask-Admin? In a world of micro-services and APIs, Flask-Admin solves the boring problem of building an admin interface on top of an existing data model. With little e…

SAP 公司代码全局参数设置及其意义

在SAP中配置公司时&#xff0c;会配置公司的全局参数&#xff0c;但这些参数具体的意思是什么估计很多同学都搞不懂&#xff0c;我也找了下资料&#xff0c;贴出来供大家参考。 设置参数路径&#xff1a;IMG→财务会计→财务会计全局设置→公司代码的全球参数→输入全局参数 账…

教你几个手机识别图片中的文字小技巧

平时我们在工作&#xff0c;有时候会拿到需要录入的纸质文件&#xff0c;如果我们使用双手逐一对照录入的话&#xff0c;就太浪费时间了。其实还有一个更简单的方法&#xff0c;就是将需要录入的文件拍摄下来&#xff0c;借助工具将图片内容转写为文字出来&#xff0c;再将其复…

Python Flask框架-开发简单博客-认证蓝图

作者&#xff1a;Eason_LYC 悲观者预言失败&#xff0c;十言九中。 乐观者创造奇迹&#xff0c;一次即可。 一个人的价值&#xff0c;在于他所拥有的。可以不学无术&#xff0c;但不能一无所有&#xff01; 技术领域&#xff1a;WEB安全、网络攻防 关注WEB安全、网络攻防。我的…

最新定制的安卓项目及设计报告——仿番茄小说APP

已录演示视频&#xff0c;想看演示视频的可以私我 《移动应用开发实践》实践报告 APP名称&#xff1a; 番茄免费小说 要求&#xff1a; 格式&#xff1a;宋体&#xff0c;小四号字&#xff1b;首行缩进&#xff1b;行距&#xff1a;1.5倍。 每人独立完成Android App的设计…

三步学会如何构建平衡二叉树(简单好理解)

何为平衡二叉树? 首先回顾一下&#xff0c;什么是平衡二叉树&#xff08;亦被称为AVL树&#xff0c;Adelson-Velskii and Landis&#xff09;。平衡二叉树主要具有以下三个特点&#xff1a; 1. 平衡二叉树首先要符合搜索二叉树的特点&#xff1a;即左子树的值比根节点小&…

排序算法之归并排序

目录 归并排序递归实现 思想 图解 代码 归并排序的非递归版本 基本思想&#xff1a; 代码 归并排序递归实现 思想 最主要的相当于二叉树遍历中的后序遍历。 ①将数组分割成多个小区间&#xff08;当只有一个元素或者并不存在的时候就不用再分割了&#xff09; ②对每一…

某工控图片上传服务 CPU 爆高分析

一&#xff1a;背景 1.讲故事 今天给大家带来一个入门级的 CPU 爆高案例&#xff0c;前段时间有位朋友找到我&#xff0c;说他的程序间歇性的 CPU 爆高&#xff0c;不知道是啥情况&#xff0c;让我帮忙看下&#xff0c;既然找到我&#xff0c;那就用 WinDbg 看一下。 二&…

Linux进程概念和控制(必备知识)

文章目录1、冯诺依曼体系结构2、操作系统3、进程<1>进程的创建<2>进程查看<3>进程状态<4>进程优先级<5> 进程地址空间4、环境变量5、进程控制<1>进程终止<2>进程等待<3>进程替换1、冯诺依曼体系结构 我们常见的计算机&#x…

软考 - 软件工程

软件过程基本概述 基本要素 方法工具过程 软件过程模型 能力成熟度模型CMM 能力成熟度模型CMMI 统一过程UP模型 针对大型项目 三大特别 用例和风险驱动以架构为中心迭代并且增量 四个阶段 起始&#xff1a;确认需求和风险评估精化&#xff1a;核心架构设计构建&#xff1a;构…

Linux内核开发 | Linux内核目录结构分析(5.4.32)

文章目录1. arch2. block3. certs4. crypto5. Documentation6. drivers7. fs8. include9. init10. ipc11. kernel12. lib13. mm14. net15. samples16. scripts17. security18. sound19. tools20. usr21. virt本文以Linux主线5.4.32内核版本进行分析。1. arch 该目录下包含了li…