def __init__(self, n):
     self.n = n
     self.waiting = 0
     self.checkin  = thread.allocate_lock()
     self.checkout = thread.allocate_lock()
     self.checkout.acquire()
 def __init__(self, n):
     self.n = n
     self.waiting = 0
     self.checkin = thread.allocate_lock()
     self.checkout = thread.allocate_lock()
     self.checkout.acquire()
# Very rudimentary test of thread module

# Create a bunch of threads, let each do some work, wait until all are done

from greentest.test_support import verbose
import random
from eventlet.green import thread
from eventlet.green import time

mutex = thread.allocate_lock()
rmutex = thread.allocate_lock() # for calls to random
running = 0
done = thread.allocate_lock()
done.acquire()

numtasks = 10

def task(ident):
    global running
    rmutex.acquire()
    delay = random.random() * numtasks * 0.02
    rmutex.release()
    if verbose:
        print 'task', ident, 'will run for', round(delay, 2), 'sec'
    time.sleep(delay)
    if verbose:
        print 'task', ident, 'done'
    mutex.acquire()
    running = running - 1
    if running == 0:
        done.release()
# Very rudimentary test of thread module

# Create a bunch of threads, let each do some work, wait until all are done

from greentest.test_support import verbose
import random
from eventlet.green import thread
from eventlet.green import time

mutex = thread.allocate_lock()
rmutex = thread.allocate_lock()  # for calls to random
running = 0
done = thread.allocate_lock()
done.acquire()

numtasks = 10


def task(ident):
    global running
    rmutex.acquire()
    delay = random.random() * numtasks * 0.02
    rmutex.release()
    if verbose:
        print 'task', ident, 'will run for', round(delay, 2), 'sec'
    time.sleep(delay)
    if verbose:
        print 'task', ident, 'done'
    mutex.acquire()
    running = running - 1
    if running == 0: