Created
July 11, 2020 07:58
-
-
Save onokatio/1577870b96723aa99620b4681430e797 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function command_1(){ | |
echo "Starting thread 1..." | |
sleep 5 | |
echo "thread 1 finished." | |
return 0 | |
} | |
function command_2(){ | |
echo "Starting thread 2..." | |
sleep 10 | |
echo "thread 2 finished." | |
return 0 | |
} | |
function command_3(){ | |
echo "Starting thread 3..." | |
sleep 1 | |
echo "thread 3 finished." | |
return 1 | |
} | |
export -f command_1 | |
export -f command_2 | |
export -f command_3 | |
jobs=() | |
jobs+=( "command_1 " ) | |
jobs+=( "command_2 " ) | |
jobs+=( "command_3 " ) | |
echo "${jobs[@]}" \ | |
| xargs -P 0 -n1 bash -c | |
echo $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment