当前位置: 首页 > 编程日记 > 正文

Android系统--TouchEvent的处理流程

TouchEvent的处理流程就是TouchEvent在View树中的传递的过程:
这个过程分为2步:
第一步,ACTION_DOWN在View树中寻找处理TouchEvent的View;
第二步,剩余的ACTION_XXX在View树传递给目标View;

第一步,ACTION_DOWN在View树中寻找处理TouchEvent的View

递归方式完成

  • 1.ACTION_DOWN从顶向下传递,找到Touch到的最底层的View;
  • 2.从底向上,查找可以处理TouchEvent的View,并记录从View到root的路径;

其中涉及到ViewGroup.dispatchTouchEvent,onInterceptTouchEvent
以及View.dispatchTouchEvent, View.onTouchEvent
递归的方式调用View/ViewGroup的dispatchTouchEvent,寻找最底层的View

ViewGroup.java

    @Overridepublic boolean dispatchTouchEvent(MotionEvent ev) {if (mInputEventConsistencyVerifier != null) {mInputEventConsistencyVerifier.onTouchEvent(ev, 1);}// If the event targets the accessibility focused view and this is it, start// normal event dispatch. Maybe a descendant is what will handle the click.if (ev.isTargetAccessibilityFocus() && isAccessibilityFocusedViewOrHost()) {ev.setTargetAccessibilityFocus(false);}boolean handled = false;if (onFilterTouchEventForSecurity(ev)) {final int action = ev.getAction();final int actionMasked = action & MotionEvent.ACTION_MASK;// Handle an initial down.if (actionMasked == MotionEvent.ACTION_DOWN) {// Throw away all previous state when starting a new touch gesture.// The framework may have dropped the up or cancel event for the previous gesture// due to an app switch, ANR, or some other state change.cancelAndClearTouchTargets(ev);resetTouchState();}// Check for interception.final boolean intercepted;if (actionMasked == MotionEvent.ACTION_DOWN|| mFirstTouchTarget != null) {final boolean disallowIntercept = (mGroupFlags & FLAG_DISALLOW_INTERCEPT) != 0;if (!disallowIntercept) {intercepted = onInterceptTouchEvent(ev);ev.setAction(action); // restore action in case it was changed} else {intercepted = false;}} else {// There are no touch targets and this action is not an initial down// so this view group continues to intercept touches.intercepted = true;}// If intercepted, start normal event dispatch. Also if there is already// a view that is handling the gesture, do normal event dispatch.if (intercepted || mFirstTouchTarget != null) {ev.setTargetAccessibilityFocus(false);}// Check for cancelation.final boolean canceled = resetCancelNextUpFlag(this)|| actionMasked == MotionEvent.ACTION_CANCEL;// Update list of touch targets for pointer down, if needed.final boolean split = (mGroupFlags & FLAG_SPLIT_MOTION_EVENTS) != 0;TouchTarget newTouchTarget = null;boolean alreadyDispatchedToNewTouchTarget = false;if (!canceled && !intercepted) {// If the event is targeting accessiiblity focus we give it to the// view that has accessibility focus and if it does not handle it// we clear the flag and dispatch the event to all children as usual.// We are looking up the accessibility focused host to avoid keeping// state since these events are very rare.View childWithAccessibilityFocus = ev.isTargetAccessibilityFocus()? findChildWithAccessibilityFocus() : null;if (actionMasked == MotionEvent.ACTION_DOWN|| (split && actionMasked == MotionEvent.ACTION_POINTER_DOWN)|| actionMasked == MotionEvent.ACTION_HOVER_MOVE) {final int actionIndex = ev.getActionIndex(); // always 0 for downfinal int idBitsToAssign = split ? 1 << ev.getPointerId(actionIndex): TouchTarget.ALL_POINTER_IDS;// Clean up earlier touch targets for this pointer id in case they// have become out of sync.removePointersFromTouchTargets(idBitsToAssign);final int childrenCount = mChildrenCount;if (newTouchTarget == null && childrenCount != 0) {final float x = ev.getX(actionIndex);final float y = ev.getY(actionIndex);// Find a child that can receive the event.// Scan children from front to back.final ArrayList<View> preorderedList = buildTouchDispatchChildList();final boolean customOrder = preorderedList == null&& isChildrenDrawingOrderEnabled();final View[] children = mChildren;for (int i = childrenCount - 1; i >= 0; i--) {final int childIndex = getAndVerifyPreorderedIndex(childrenCount, i, customOrder);final View child = getAndVerifyPreorderedView(preorderedList, children, childIndex);// If there is a view that has accessibility focus we want it// to get the event first and if not handled we will perform a// normal dispatch. We may do a double iteration but this is// safer given the timeframe.if (childWithAccessibilityFocus != null) {if (childWithAccessibilityFocus != child) {continue;}childWithAccessibilityFocus = null;i = childrenCount - 1;}if (!canViewReceivePointerEvents(child)|| !isTransformedTouchPointInView(x, y, child, null)) {ev.setTargetAccessibilityFocus(false);continue;}newTouchTarget = getTouchTarget(child);if (newTouchTarget != null) {// Child is already receiving touch within its bounds.// Give it the new pointer in addition to the ones it is handling.newTouchTarget.pointerIdBits |= idBitsToAssign;break;}resetCancelNextUpFlag(child);if (dispatchTransformedTouchEvent(ev, false, child, idBitsToAssign)) {// Child wants to receive touch within its bounds.mLastTouchDownTime = ev.getDownTime();if (preorderedList != null) {// childIndex points into presorted list, find original indexfor (int j = 0; j < childrenCount; j++) {if (children[childIndex] == mChildren[j]) {mLastTouchDownIndex = j;break;}}} else {mLastTouchDownIndex = childIndex;}mLastTouchDownX = ev.getX();mLastTouchDownY = ev.getY();newTouchTarget = addTouchTarget(child, idBitsToAssign);alreadyDispatchedToNewTouchTarget = true;break;}// The accessibility focus didn't handle the event, so clear// the flag and do a normal dispatch to all children.ev.setTargetAccessibilityFocus(false);}if (preorderedList != null) preorderedList.clear();}if (newTouchTarget == null && mFirstTouchTarget != null) {// Did not find a child to receive the event.// Assign the pointer to the least recently added target.newTouchTarget = mFirstTouchTarget;while (newTouchTarget.next != null) {newTouchTarget = newTouchTarget.next;}newTouchTarget.pointerIdBits |= idBitsToAssign;}}}// Dispatch to touch targets.if (mFirstTouchTarget == null) {// No touch targets so treat this as an ordinary view.handled = dispatchTransformedTouchEvent(ev, canceled, null,TouchTarget.ALL_POINTER_IDS);} else {// Dispatch to touch targets, excluding the new touch target if we already// dispatched to it.  Cancel touch targets if necessary.TouchTarget predecessor = null;TouchTarget target = mFirstTouchTarget;while (target != null) {final TouchTarget next = target.next;if (alreadyDispatchedToNewTouchTarget && target == newTouchTarget) {handled = true;} else {final boolean cancelChild = resetCancelNextUpFlag(target.child)|| intercepted;if (dispatchTransformedTouchEvent(ev, cancelChild,target.child, target.pointerIdBits)) {handled = true;}if (cancelChild) {if (predecessor == null) {mFirstTouchTarget = next;} else {predecessor.next = next;}target.recycle();target = next;continue;}}predecessor = target;target = next;}}// Update list of touch targets for pointer up or cancel, if needed.if (canceled|| actionMasked == MotionEvent.ACTION_UP|| actionMasked == MotionEvent.ACTION_HOVER_MOVE) {resetTouchState();} else if (split && actionMasked == MotionEvent.ACTION_POINTER_UP) {final int actionIndex = ev.getActionIndex();final int idBitsToRemove = 1 << ev.getPointerId(actionIndex);removePointersFromTouchTargets(idBitsToRemove);}}if (!handled && mInputEventConsistencyVerifier != null) {mInputEventConsistencyVerifier.onUnhandledEvent(ev, 1);}return handled;}
     private boolean dispatchTransformedTouchEvent(MotionEvent event, boolean cancel,View child, int desiredPointerIdBits) {final boolean handled;// Canceling motions is a special case.  We don't need to perform any transformations// or filtering.  The important part is the action, not the contents.final int oldAction = event.getAction();if (cancel || oldAction == MotionEvent.ACTION_CANCEL) {event.setAction(MotionEvent.ACTION_CANCEL);if (child == null) {handled = super.dispatchTouchEvent(event);} else {handled = child.dispatchTouchEvent(event);}event.setAction(oldAction);return handled;}// Calculate the number of pointers to deliver.final int oldPointerIdBits = event.getPointerIdBits();final int newPointerIdBits = oldPointerIdBits & desiredPointerIdBits;// If for some reason we ended up in an inconsistent state where it looks like we// might produce a motion event with no pointers in it, then drop the event.if (newPointerIdBits == 0) {return false;}// If the number of pointers is the same and we don't need to perform any fancy// irreversible transformations, then we can reuse the motion event for this// dispatch as long as we are careful to revert any changes we make.// Otherwise we need to make a copy.final MotionEvent transformedEvent;if (newPointerIdBits == oldPointerIdBits) {if (child == null || child.hasIdentityMatrix()) {if (child == null) {handled = super.dispatchTouchEvent(event);} else {final float offsetX = mScrollX - child.mLeft;final float offsetY = mScrollY - child.mTop;event.offsetLocation(offsetX, offsetY);handled = child.dispatchTouchEvent(event);event.offsetLocation(-offsetX, -offsetY);}return handled;}transformedEvent = MotionEvent.obtain(event);} else {transformedEvent = event.split(newPointerIdBits);}// Perform any necessary transformations and dispatch.if (child == null) {handled = super.dispatchTouchEvent(transformedEvent);} else {final float offsetX = mScrollX - child.mLeft;final float offsetY = mScrollY - child.mTop;transformedEvent.offsetLocation(offsetX, offsetY);if (! child.hasIdentityMatrix()) {transformedEvent.transform(child.getInverseMatrix());}handled = child.dispatchTouchEvent(transformedEvent);}// Done.transformedEvent.recycle();return handled;}
            if (actionMasked == MotionEvent.ACTION_DOWN|| mFirstTouchTarget != null) {final boolean disallowIntercept = (mGroupFlags & FLAG_DISALLOW_INTERCEPT) != 0;if (!disallowIntercept) {intercepted = onInterceptTouchEvent(ev);ev.setAction(action); // restore action in case it was changed} else {intercepted = false;}} else {// There are no touch targets and this action is not an initial down// so this view group continues to intercept touches.intercepted = true;}

从这段代码看出,在ViewGroup.dispatchTouchEvent中调用onInterceptTouchEvent
调用的条件是: 1.ACTION_DOWN

        2.mFirstTouchTarget != null

mFirstTouchTarget != null

ViewGroup.dispatchTouchEvent:

if (!canceled && !intercepted) {if (actionMasked == MotionEvent.ACTION_DOWN|| (split && actionMasked == MotionEvent.ACTION_POINTER_DOWN)|| actionMasked == MotionEvent.ACTION_HOVER_MOVE) {if (newTouchTarget == null && childrenCount != 0) {... ...for (int i = childrenCount - 1; i >= 0; i--) {... ...if (dispatchTransformedTouchEvent(ev, false, child, idBitsToAssign)) {... ...newTouchTarget = addTouchTarget(child, idBitsToAssign);... ...}... ...}}}
}

1.传递ACTION_DOWN
child.dispatchTouchEvent()
调用子View的dispatchTouchEvent方法
2.把dispatchTouchEvent返回值为true的子View串成一个链表
如果该链表为空,说明该View是最底层的View;
3.找到最底层的View,再从该View向上查找处理TouchEvent的目标View
super.dispatchTouchEvent()
这整个过程
View.java

    public boolean dispatchTouchEvent(MotionEvent event) {// If the event should be handled by accessibility focus first.if (event.isTargetAccessibilityFocus()) {// We don't have focus or no virtual descendant has it, do not handle the event.if (!isAccessibilityFocusedViewOrHost()) {return false;}// We have focus and got the event, then use normal event dispatch.event.setTargetAccessibilityFocus(false);}boolean result = false;if (mInputEventConsistencyVerifier != null) {mInputEventConsistencyVerifier.onTouchEvent(event, 0);}final int actionMasked = event.getActionMasked();if (actionMasked == MotionEvent.ACTION_DOWN) {// Defensive cleanup for new gesturestopNestedScroll();}if (onFilterTouchEventForSecurity(event)) {if ((mViewFlags & ENABLED_MASK) == ENABLED && handleScrollBarDragging(event)) {result = true;}//noinspection SimplifiableIfStatementListenerInfo li = mListenerInfo;if (li != null && li.mOnTouchListener != null&& (mViewFlags & ENABLED_MASK) == ENABLED&& li.mOnTouchListener.onTouch(this, event)) {result = true;}if (!result && onTouchEvent(event)) {result = true;}}if (!result && mInputEventConsistencyVerifier != null) {mInputEventConsistencyVerifier.onUnhandledEvent(event, 0);}// Clean up after nested scrolls if this is the end of a gesture;// also cancel it if we tried an ACTION_DOWN but we didn't want the rest// of the gesture.if (actionMasked == MotionEvent.ACTION_UP ||actionMasked == MotionEvent.ACTION_CANCEL ||(actionMasked == MotionEvent.ACTION_DOWN && !result)) {stopNestedScroll();}return result;}

View.dispatchTouchEvent调用了mOnTouchListener.onTouch和onTouchEvent;
当onTouchEvent返回true,代表该View处理TouchEvent

            if (li != null && li.mOnTouchListener != null&& (mViewFlags & ENABLED_MASK) == ENABLED&& li.mOnTouchListener.onTouch(this, event)) {result = true;}if (!result && onTouchEvent(event)) {result = true;}

第二步,剩余的ACTION_XXX在View树传递给目标View;

    if (mFirstTouchTarget == null) {// No touch targets so treat this as an ordinary view.handled = dispatchTransformedTouchEvent(ev, canceled, null,TouchTarget.ALL_POINTER_IDS);} else {TouchTarget predecessor = null;TouchTarget target = mFirstTouchTarget;while (target != null) {final TouchTarget next = target.next;if (alreadyDispatchedToNewTouchTarget && target == newTouchTarget) {handled = true;} else {final boolean cancelChild = resetCancelNextUpFlag(target.child)|| intercepted;if (dispatchTransformedTouchEvent(ev, cancelChild,target.child, target.pointerIdBits)) {handled = true;}if (cancelChild) {if (predecessor == null) {mFirstTouchTarget = next;} else {predecessor.next = next;}target.recycle();target = next;continue;}}predecessor = target;target = next;}

遍历子View的链表传递ACTION_XXX

相关文章:

搜索引擎中的URL散列

散列&#xff08;hash&#xff09;也就是哈希&#xff0c;是信息存储和查询所用的一项基本技术。在搜索引擎中网络爬虫在抓取网页时为了对网页进行有效地排重必须对URL进行散列&#xff0c;这样才能快速地排除已经抓取过的网页。最理想的状态是对联网上所有的网页都分配一个哈希…

c++各种数据类型表示范围

符号属性 长度属性 基本型 所占位数 取值范围 输入符举例 输出符举例 -- -- char 8 -2^7 ~ 2^7-1 %c %c、%d、%usigned -- char 8 -2^7 ~ 2^7-1 %c …

原来Python用得好,工作这么好找

Python是多数平台上写脚本和快速开发应用的编程语言&#xff0c;适用场景非常广&#xff0c;Web开发、大数据分析、机器学习、自动化运维/测试&#xff0c;甚至日常工作中的各种各样的问题都能用Python来解决。Python不仅可以批量处理上百个Excel、Word、PDF文件&#xff0c;工…

Litmus代码质量平台实践总结

背景代码质量在项目开发中是一个很重要的地方&#xff0c;更好的质量的代码&#xff0c;能够产生更少的bug&#xff0c;也能使开发人员更不容易犯错&#xff0c;产品的质量得到提升。那么怎么定义代码质量&#xff0c;怎么测量以及如何展现就成为我们内部平台Litmus的主要探索领…

到底什么是hash?它起什么作用?

从emule诞生到现在也已经有了两年左右时间了&#xff0c;随着emule的普及&#xff0c;喜欢他的人也越来越多&#xff0c;但是由于emule对技术相应有一个门槛&#xff0c;不像bt那么容易上手&#xff0c;所以很多朋友很长时间以来一直都有这样或那样的疑问&#xff0c;今天是周末…

20个精美图表,教你玩转 Pyecharts 可视化

作者 |俊欣来源 |关于数据分析与可视化本篇文章我们将继续聚焦c模块并且用它来绘制精美的图表&#xff0c;希望读者在看完之后会有不少收获01内嵌饼状图内接一个环状的饼图&#xff0c;里面还有一个饼状的图(Pie().add(series_name"访问来源",data_pair[list(z) for …

【SICP练习】136 练习3.67

练习3-67 原文 Exercise 3.67. Modify the pairs procedure so that (pairs integers integers) will produce the stream of all pairs of integers (i,j) (without the condition i < j). Hint: You will need to mix in an additional stream. 代码 (define (all-pairs s…

glibc方式安装mysql

下载安装包 mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz创建mysql用户useradd -r mysql -s /sbin/nologin解压文件tar -zxvf mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz -C /opt/改名mv /opt/mysql-5.6.38-linux-glibc2.12-x86_64/ /opt/mysql-5.6创建数据目录mkdir /data更…

淘宝网7年变化图--建议非美工UED人员也看看

从2003年开始&#xff0c;这么几年间淘宝网首页截图&#xff0c;UED美工和开发人员都可以看看。图片来自www.infoq.com网站 的PPT

Github 一夜爆火:这份金九银十 Java 面试手册我给跪了

这几天给筒子们整理了一份《Java面试手册》&#xff0c;106页&#xff0c;目前大约6万字左右&#xff0c;初衷也很简单&#xff0c;就是希望在面试的时候能够帮助到大家&#xff0c;减轻大家的负担和节省时间。废话不多说&#xff0c;本手册目前为第一版&#xff0c;后续慢慢也…

a different object with the same identifier value was already associated with the session

当出现a different object with the same identifier value was already associated with the session时&#xff0c;一般是因为在hibernate中同一个session里面有了两个相同标识但是是不同实体。 我直接将接受需要比较的id的list<ab>换成了list<object[]>,再直接将…

【转】unity3d 在UGUI中制作自适应调整大小的滚动布局控件

转自 http://blog.csdn.net/rcfalcon/article/details/43459387 在游戏中&#xff0c;我们很多地方需要用到scroll content的概念&#xff1a;我们需要一个容器&#xff0c;能够指定布局方式&#xff08;比如横排排列、竖排排列、网格排列&#xff09;等。然后我们向其中填充内…

(转)径向模糊效果shader

转自&#xff1a;http://blog.csdn.net/xoyojank/article/details/5146297 最先在这里看到:http://www.gamerendering.com/2008/12/20/radial-blur-filter/ 这效果在鬼泣4中切换场景时见过, 极品飞车12的运动模糊也有这种感觉. 原理: 确定一个中心点(如0.5, 0.5), 跟当前像素连…

初次体验hiphop-php

facebook在github上发布了hiphop-php的源代码。之前听说这玩意能把php代码翻译成c代码&#xff0c;然后带来巨大的性能提升&#xff0c;所以第一时间编译了一份hiphop-php。 我的机器环境是 Centos 5.3 x86_648G内存Intel(R) Xeon(R) CPU E5420 2.50GHz 安装注意事项 编译…

MySQL之父等国际数据库掌门人齐聚,1024 程序员节全体大会重磅官宣!

10月23-24日&#xff0c;由CSDN、长沙市政府及多家机构联合主办的第二届“长沙中国1024程序员节”&#xff08;1024.csdn.net&#xff09;将盛大举行。今年程序员节活动囊括&#xff1a;岳麓书院尖峰对话&#xff0c;2021技术英雄会&#xff0c;9场热门技术主题论坛/专场、第16…

通过yum安装配置lamp

1、安装httpdyum install httpd创建测试文件cd /var/www/htmlvim index.php加入以下内容<html><head><title>PHP Page</title></head><body><h1>PHP start</h1> <?phpphpinfo(); ?><h1>PHP end</h1> <…

PHP“Cannot use object of type stdClass as array”

php再调用json_decode从字符串对象生成json对象时&#xff0c;如果使用[]操作符取数据&#xff0c;会得到下面的错误错误&#xff1a;Cannot use object of type stdClass as array产生原因&#xff1a;展开 -PHP$res json_decode($res);$res[key]; //把 json_decode() 后的对…

RMAN_学习笔记1_RMAN Structure概述和体系结构

2014-12-23 Created By BaoXinjian 一、摘要 是一种用于集备份(backup)、还原(restore)和恢复(recover)数据库于一体的Oracle 工具&#xff0c;支持命令行及图形界面操作 能够备份整个数据库、表空间、数据文件、控制文件、归档文件以及Spfile参数文件。 支持增量数据块级别的备…

全球缺芯大潮中,以软代硬能否另辟蹊径?

在5G和人工智能的技术浪潮如约而至以后&#xff0c;业内人士无不对IoT产业的未来报以极大的期待。以人工智能和家居设备为基础&#xff0c;再加上算力与网络支持&#xff0c;有理由相信未来IoT相关产业必将迎来爆发。然而今年&#xff0c;席卷全球的芯片产能不足问题影响到了各…

Xtrabackup实现数据的备份与恢复

Xtrabackup介绍Xtrabackup是由percona开源的免费数据库热备份软件&#xff0c;它能对InnoDB数据库和XtraDB存储引擎的数据库非阻塞地备份&#xff08;对于MyISAM的备份同样需要加表锁&#xff09;&#xff1b;mysqldump备份方式是采用的逻辑备份&#xff0c;其最大的缺陷是备份…

最简单的CI框架入门示例--数据库取数据

这个写给初学者看&#xff0c;这是最简单可以调通的例子&#xff0c;网上很多例子其实初学者本地跑不通&#xff0c;缺这少那。 1.下载CI框架&#xff08;自己找&#xff09;2.配置 database.php配置&#xff1a; 为数据库服务器设置 connection 参数&#xff1a; $db[defau…

ST-GCN 实现人体姿态行为分类

作者 | 李秋键 出品 | AI科技大本营&#xff08;ID:rgznai100&#xff09; 引用 人体行为识别是计算机视觉及机器学习方面的热门研究领域。它在对视频中的人类行为进行运动分析、行为识别乃至延伸至人机交互领域都有着非常广泛的应用。研究初期&#xff0c;人体行为识别主要是以…

【原创】Kakfa utils源代码分析(三)

Kafka utils包最后一篇~~~ 十五、ShutdownableThread.scala可关闭的线程抽象类&#xff01; 继承自Thread同时还接收一个boolean变量isInterruptible表明是否允许中断。既然是可关闭的&#xff0c;因此一定不是守护线程&#xff0c;而是一个用户线程(不会阻塞JVM关闭)。提供的方…

Oracle的分页查询

为什么80%的码农都做不了架构师&#xff1f;>>> 因为Oracle不像MySQL一样有limit函数来实现分页查找&#xff0c;oracle要实现分页查询可使用关键字rownum来处理。使用rownum有以下几点需要注意&#xff1a; 1、ROWNUM存在使用规则&#xff0c;在单个子查询中&…

微软成功抵御峰值高达 2.4Tbps 的 DDoS 攻击

整理 | 祝涛 出品 | CSDN&#xff08;ID&#xff1a;CSDNnews&#xff09;微软表示&#xff0c;他们成功抵御了一场发生于8月份的2.4Tbps分布式拒绝服务&#xff08;DDoS&#xff09;攻击&#xff0c;这次攻击超过了去年针对亚马逊Web服务的2.3Tbps最大攻击。这场攻击持续…

百度吴甜:首席AI架构师培养计划持续为行业输送高端复合型AI人才

CSDN 导语&#xff1a; 随着 AI 技术的发展&#xff0c;关注 AI 的开发者与日俱增&#xff1a;据 CSDN 发布的《中国 AI 应用开发者报告》显示&#xff0c;在 CSDN 的注册开发者中&#xff0c;689 万开发者有阅读、撰写和研究 AI 技术行为&#xff0c;其中精准聚焦 AI 学习和应…

Htaccess文件是什么以及Windows下自由创建.htaccess文件的N种方法

.htaccess是什么 概述来说&#xff0c;htaccess文件是Apache服务器中的一个配置文件&#xff0c;它负责相关目录下的网页配置。 通过htaccess文件&#xff0c;可以帮我们实现&#xff1a;网页301重定向、自定义404错误页面、改变文件扩展名、允许/阻止特定的用户或者目录的访…

Linux grep,egrep及相应的正则表达式用法详解

linux在进行文本处理过程中的文本搜索工具称为正则表达式。文本搜索工具有grep、egrep、fgrep,egrep为正则表达式的扩展正则表达式&#xff0c;fgrep用于搜索文本字符串&#xff0c;与 grep 和 egrep 命令不同&#xff0c;因为它搜索字符串而不是搜索匹配表达式的模式。grep的含…

Java GC 日志解析

JVM 在Java应用程序优化中是不可缺少的一大重项&#xff0c;如何合理配置Java参数&#xff0c;如果验证配置参数的有效性&#xff0c;从GC日志中可以获得很重要的提示&#xff0c;以下是笔者对GC垃圾收集器默认开启的组合日志的部分的解析&#xff0c;希望能帮到想学习的同学O(…

MySQL 备份和恢复策略

在数据库表丢失或损坏的情况下&#xff0c;备份你的数据库是很重要的。如果发生系统崩溃&#xff0c;你肯定想能够将你的表尽可能丢失最少的数据恢复到崩溃发生时的状态。本文主要对MyISAM表做备份恢复。 备份策略一&#xff1a;直接拷贝数据库文件&#xff08;不推荐&#xff…