#! / Usr / bin / env python
IMPORT OS
Import Time
Import threading
# Process function
Def PrintThread (N):
Print N,
"-> process creation"
For a
In Range (4):
Print A
Time.sleep (1)
Print N,
"-> process end"
Sem.release ()
IF __NAME__ == '__ main__':
Maxthread = 5
#
SEM = threading.boundedsemaphore (Maxthread)
For a
In Range (12):
Sem.acquire ()
Threading.Thread (Target = Printthread, Args = (a,)). START ()
Print
"All Thread Has Create, Wait for All Thread EXIT."
For a
In RanThread:
Sem.acquire ();
Print
"All thread exit"