Пример #1
0
def main():
    lunch_break = threading.Lock()
    finish = threading.Event()
    allen = Thread(work, 'Allen', lunch_break, finish)
    bob = Thread(work, 'Bob', lunch_break, finish)
    time.sleep(.4)
    finish.set()
Пример #2
0
def main():
    a1_action = Semaphore(0)
    b1_action = Semaphore(0)
    a = Thread(a_task, a1_action, b1_action)
    b = Thread(b_task, a1_action, b1_action)
    a.join()
    b.join()
Пример #3
0
def main():
    barrier = threading.Barrier(total_threads, show_barrier)
    counter_lock = threading.Lock()
    threads = [Thread(work, t, barrier)
                for t in range(total_threads)]
    for thread in threads:
        thread.join()
Пример #4
0
def main():
    barrier = Semaphore(0)
    counter_lock = threading.Lock()
    threads = [
        Thread(work, t, barrier, counter_lock) for t in range(total_threads)
    ]
    for thread in threads:
        thread.join()
Пример #5
0
def main():
    a1_action = Semaphore(0)
    b1_action = Semaphore(0)
    a = Thread(a_task, a1_action, b1_action)
    b = Thread(b_task, a1_action, b1_action)
    a.join()
    b.join()
def main():
    updating = Lock()
    threads = [Thread(update, t, updating) for t in range(100)]
    for thread in threads:
        thread.join()
    print('\ncount:', count)
Пример #7
0
def main():
    reading = Semaphore(0)
    reader = Thread(read_task, reading)
    display = Thread(display_task, reading)
    reader.join()
    display.join()
Пример #8
0
def main():
    q = queue.Queue(1)
    reader = Thread(read_task, q)
    display = Thread(display_task, q)
    reader.join()
    display.join()
Пример #9
0
def main():
    threads = [Thread(update) for t in range(100)]
    for thread in threads:
        thread.join()
    print('count:', count)
Пример #10
0
def main():
    updating = Semaphore(1)
    threads = [Thread(update, t, updating) for t in range(100)]
    for thread in threads:
        thread.join()
    print('count:', count)
Пример #11
0
def main():
    call = threading.Event()
    Thread(allen_day, call)
    Thread(bob_day, call)
Пример #12
0
def main():
    reading = Semaphore(0)
    reader = Thread(read_task, reading)
    display = Thread(display_task, reading)
    reader.join()
    display.join()