Hi,

Here is a code example to visualize my problem.

----------------------------------------------------------------------------------
import thread
import threading
from time import sleep

def a():
        print "exec a"
        sleep(1)

def b():
        print "exec b"
        sleep(4)

def c():
        print "exec c"
        sleep(3)

def d():
        print "exec d"
        sleep(2)

def e():
        print "exec e"
        sleep(2)

def s():
        print "exec s"
        # ...
        # code which synchronize the incoming three threads
        # ....
        print "in synch"


def main(sstr):
        nodes = sstr.split(",")
        print nodes
        for n in nodes:
                if n is "a":
                        a()
                elif n is "b":
                        b()
                elif n is "c":
                        c()
                elif n is "d":
                        d()
                elif n is "e":
                        e()
                elif n is "s":
                        s()
                else:
                        print "unkown"


#A
threading.Thread(target=main, args=("b,c,s,e",)).start()
#B
threading.Thread(target=main, args=("c,s,e",)).start()
#C
threading.Thread(target=main, args=("s,e",)).start()
#D
threading.Thread(target=main, args=("c,e",)).start()
----------------------------------------------------------------------------------

The threads which arrives to the s function should wait for each other
until the last one. So A, B, and C executes the last function
'together', while D executes it seperate.
I only know that three threads have to be in synch.

I've been now spending a week on the problem.
The same problem should also be solved in C++. Buts thats another
issue. (Someone knows, too?)

Thanks,

Martin

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to