Q:

Python: Limit number of process calls by os.system

I need to run programs parallel, 3 at a time.  I tried the following but when programC finished before A and B, it does not work.  How can I limit the number of running programs to, say, at most 3 at any time. 
for i in range(10):
     os.system("xterm -e program " + i + "a" + " &")
     os.system("xterm -e program " + i + "b" + " &") 
     os.system("xterm -e program " + i + "c" + " ")

A:

Here my solution, though I will select a better answer:
for i in range(10):
    a = subprocess. Popen(["xterm -e program"+ i + " a" ],shell=True)
    b = subprocess. Popen(["xterm","-e","program",i," b"])
    c = subprocess. Popen(["xterm","-e","program",i," c"])
    a.wait()
    b.wait()
    c.wait()

