Created
March 19, 2013 16:44
-
-
Save shinofara/5197761 to your computer and use it in GitHub Desktop.
シェルスクリプトで、マルチスレッド処理風実装 ref: http://qiita.com/items/381c8f57bf39c52d240a
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
java -jar /usr/bin/compiler.jar --js=test1.js --js_output_file=test1.min.js | |
java -jar /usr/bin/compiler.jar --js=test2.js --js_output_file=test2.min.js | |
java -jar /usr/bin/compiler.jar --js=test3.js --js_output_file=test3.min.js | |
java -jar /usr/bin/compiler.jar --js=test4.js --js_output_file=test4.min.js | |
java -jar /usr/bin/compiler.jar --js=test5.js --js_output_file=test5.min.js | |
java -jar /usr/bin/compiler.jar --js=test6.js --js_output_file=test6.min.js | |
java -jar /usr/bin/compiler.jar --js=test7.js --js_output_file=test7.min.js | |
java -jar /usr/bin/compiler.jar --js=test8.js --js_output_file=test8.min.js |
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
echo "マルチスレッド開始"; | |
OUTPUT_FILE="command_list.txt" | |
n=3; | |
i=0 | |
while read line | |
do | |
# バックグラウンド | |
eval ${line} & | |
# 直前のPIDを取得 | |
pid[${i}]=$! | |
#3以上になったら、0 | |
i=`expr $i \+ 1`; | |
if [ ${n} -eq ${i} ];then | |
wait; | |
i=0; | |
fi | |
done < ${OUTPUT_FILE} | |
echo "マルチスレッド終了"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment