linux shell多线程操作
来源:互联网 发布:香蕉网络电视手机版 编辑:程序博客网 时间:2024/06/11 14:52
原理:linux的shell命令可以实现多线程运行,并且线程间具备通信机制。
1、单线程
原理:默认的情况下,Shell脚本中的命令是串行执行的,必须等到前一条命令执行完后才执行接下来的命令。
实例:
- #!/bin/bash
- for(( i = 0; i < ${count}; i++ ))
- do
- commands1
- done
- commands2
2、多线程
方式:
{ command_x }&
原理:大括号以内为一个子线程运行。
实例:
- #!/bin/bash
- for(( i = 0; i < ${count}; i++ ))
- do
- {
- commands1
- }&
- done
- wait
- commands2
注意:wait函数,该函数将等待后台所有子进程结束。正是因为有了此函数,才能保证commands2在所有commands1执行完后再执行。
0 0
- linux shell多线程操作
- shell 批量操作 多线程
- 【shell】linux shell 实现多线程
- linux shell 实现多线程
- linux shell 实现多线程
- linux shell 实现多线程
- Linux Shell脚本 多线程
- linux shell 实现多线程
- Linux shell 实现多线程
- Linux shell 查找操作
- [Linux]:shell 字符串操作
- Linux shell 快捷操作
- linux shell 字符串操作
- linux shell 字符串操作
- linux shell 快捷键,操作!
- linux shell基本操作
- linux shell字符串操作
- linux shell 操作mysql
- 第二章 设计模式之模板模式
- js代码:在光标处添加字符串
- ionic drag
- sysstat下载介绍
- LRU算法原理
- linux shell多线程操作
- php curl无法开启的问题
- 设计相关1-设计原则
- android TextView ellipsize 只显示一个点 解决方案
- Microsoft Office 2016(ProPlus/Visio/Project) VOL 简体中文版
- BZOJ3221 [Codechef FEB13] Obserbing the tree树上询问
- kubernetes1.1.8 使用Deployment
- 字符串的存储
- 安卓添加布局动画效果