17.12.2012 Views

Programmation PYTHON - Zenk - Security - Repository

Programmation PYTHON - Zenk - Security - Repository

Programmation PYTHON - Zenk - Security - Repository

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

stdout.write('.')<br />

stdout.flush()<br />

sleep(0.2)<br />

stdout.write('100M')<br />

_100_metres.set()<br />

class Coureur2(Thread):<br />

def run(self):<br />

_100_metres.wait()<br />

for i in range(10):<br />

stdout.write('.')<br />

stdout.flush()<br />

sleep(0.2)<br />

stdout.write('200M')<br />

_200_metres.set()<br />

class Coureur3(Thread):<br />

def run(self):<br />

_200_metres.wait()<br />

for i in range(10):<br />

stdout.write('.')<br />

stdout.flush()<br />

sleep(0.2)<br />

stdout.write('300M')<br />

_300_metres.set()<br />

class Coureur4(Thread):<br />

def run(self):<br />

_300_metres.wait()<br />

for i in range(10):<br />

stdout.write('.')<br />

stdout.flush()<br />

sleep(0.2)<br />

print('400M')<br />

if __name__ == '__main__':<br />

c4 = Coureur4()<br />

c4.start()<br />

Coureur3().start()<br />

Coureur2().start()<br />

Coureur1().start()<br />

# attente du dernier coureur<br />

c4.join()<br />

Bonnes pratiques et optimisation du code<br />

CHAPITRE 13<br />

Les événements et les threads permettent de modéliser des problèmes complexes<br />

d’interaction.<br />

461

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!