多线程脚本的统制办法

多线程脚本的控制办法
#!/bin/bash
function hello_thread(){
        echo "thread $1 start at `date`"
        sleep 10
}
thread_pid=()
for i in `seq 9`; do
        hello_thread $i &
        thread_pid=("${thread_pid[@]}" "$!")
done
while [ ${#thread_pid[@]} -ne 0 ]; do
        for pid_idx in ${!thread_pid[*]}; do
                pid_val=${thread_pid[$pid_idx]}
                kill -s 0 $pid_val &>/dev/null || unset thread_pid[$pid_idx] 
        done
        thread_pid=("${thread_pid[@]}")
        sleep 30
done
复制代码
------解决方案--------------------
接分的来了,你累不?