A Lock allows blocking execution until it has been unlocked. It keeps track
of how often release has been called, and blocks exactly as many wait
calls.
The order of the release and wait calls is irrelevant. That is, a Lock
can be released before anyone waits for it. In that case, the wait call
will execute immediately.
Usage example:
	var lock = new Lock();
	var elements = [1, 2, 3];
	for (element in elements) {
		// Create one thread per element
		new Thread(function() {
			trace(element);
			Sys.sleep(1);
			// Release once per thread = 3 times
			lock.release();
		});
	}
	for (_ in elements) {
		// Wait 3 times
		lock.wait();
	}
	trace("All threads finished");