Hmissa
Posts: 6
Joined: Tue Jul 07, 2015 9:27 am

Thread in script shell

Tue Jul 07, 2015 9:37 am

i have two appli, the first is a C program "appli1" and the second is a java program ""appli2"
both application have a shared resource, for that I want to execute a thread in a shell script:
in a loop:
APPLI1 for 1 minute and sleep
APPLI2 for 1 minute and sleep

how can i do that? and thx

User avatar
joan
Posts: 14936
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Thread in script shell

Tue Jul 07, 2015 11:06 am

You really ought to change the programs to synchronise the way they work.

You can try the following

Code: Select all

#!/bin/bash

./appl1
sleep 60
killall -s STOP appli1
 ./appli2
sleep 60
killall -s STOP appli2
for ((;;))
do
   killall -s CONT ./appl1
   sleep 60
   killall -s STOP appli1
   killall -s CONT ./appli2
   sleep 60
   killall -s STOP ./appli2
done

Return to “General programming discussion”