Console scripts execution from Java program

Go To StackoverFlow.com

1

I am thinking about calling bash scripts from java program. I need to execute it once in a minute, but as many times as a number of clients from DB (around 1000).

That's going to be something like curl -o /dev/null -s -t "%{total_time}" | awk .... I believe that this is better to be implemented as bash script rather than in Java, because it will be not that lightweight but demand lots of things in java code to reproduce the behavior.

I know about Runtime.exec(), but it creates a system process each time. I guess it would be OK to create 1-10 such processes, but 1000 system processes is not acceptable.

What is the better way of doing that?

2012-04-03 19:58
by glaz666


0

You can use Runtime.exec waiting for ending (waitFor()) concurrently with a fixed size thread pool.

2012-04-03 20:38
by Luca
Ads