Why multi-threading in shell ?
Shell provides a high level language in a simple coding style . It has a lot of features you never find those in other programming languages . like other languages shell does not support many features such as multi-threading . Multi-threading allows programs to :
1- use max possible cpu load
2- get optimized for multi-core CPUs
3- support multi-tasking features
4- run codes in background of another code
For example , there is a simple script with a user menu . I want to add a background music to make program more attractive but I can not do that ! shell does not allow me to play a music and show menu . It has only one thread and this limits the program to wait for one task then start another
What is "Shell Multi-Threading Project" ?
Now its time to start multi-threading in shell . Shell Multi Threading Project is an alternative to use multi-threading in shell scripts . It allows you to use max power of cpu , optimize your scripts for multi-core CPUs and manage/run multi task at one time ! Shell Multi threading tool is compiled for ARM ( androideabi ) but will be compiled for linux X86-64 soon .
How to use it ?
First of all Download lastest version from this topic . move the binary file to your $PATH ( which is /system/bin/ in Android and /sbin/ in cwm ).
now its installed ! use it :
for example :
both threads start at the same time . thread 1 waits 1 seconds and then prints "hello" , 1 second later thread 2 finishes its 2 second sleep and prints "world!"
you can use more POSIX threads :
now lets solve the example "playing music while our script menu is running :"
Downloads
Shell Multi Threading Binary : 46 kb
Using POSIX shell multi threading binary is free for " non-commercial projects with credits to shell multi threading project and its owner ".
Shell provides a high level language in a simple coding style . It has a lot of features you never find those in other programming languages . like other languages shell does not support many features such as multi-threading . Multi-threading allows programs to :
1- use max possible cpu load
2- get optimized for multi-core CPUs
3- support multi-tasking features
4- run codes in background of another code
For example , there is a simple script with a user menu . I want to add a background music to make program more attractive but I can not do that ! shell does not allow me to play a music and show menu . It has only one thread and this limits the program to wait for one task then start another
What is "Shell Multi-Threading Project" ?
Now its time to start multi-threading in shell . Shell Multi Threading Project is an alternative to use multi-threading in shell scripts . It allows you to use max power of cpu , optimize your scripts for multi-core CPUs and manage/run multi task at one time ! Shell Multi threading tool is compiled for ARM ( androideabi ) but will be compiled for linux X86-64 soon .
How to use it ?
First of all Download lastest version from this topic . move the binary file to your $PATH ( which is /system/bin/ in Android and /sbin/ in cwm ).
now its installed ! use it :
Code:
posix 'command 1' 'command 2'Code:
posix 'sleep 1 && echo "hello"' 'sleep 2 && echo "world !"'you can use more POSIX threads :
Code:
posix 'posix "command1" "command2"' 'posix "command3" "command4"Code:
posix "stagefright -a audio.mp3" "./script_menu"Shell Multi Threading Binary : 46 kb
Using POSIX shell multi threading binary is free for " non-commercial projects with credits to shell multi threading project and its owner ".