Java_Shell多线程

    #!/bin/bash  
    source ~/.bashrc  
      
    fun(){  
        echo "fun is begin.timeNum:$timeNum"  
        local timeNum=$1  
        sleep $timeNum &  
        wait #这个只等待wait前面sleep  
          
        echo "fun is end.timeNum:$timeNum"  
    }  
      
    fun 10 &  
    fun 20 &  
      
    wait #如果fun里面没有wait,则整个脚本立刻退出,不会等待fun里面的sleep  
    echo "all is ending"  

 

posted @ 2016-09-21 22:26  MrMrCash  阅读(255)  评论(0编辑  收藏  举报