Added mutex to handles

handle_create, handle_get and handle_destroy are thread-safe now.
A lock to a handle can be acquired by invoking handle_aqcuire and released by handle_release.
Only one thread can acquire a lock of a specific handle at the same time, so other threads that call handle_acquire will block until the thread which helds the monitor calls handle_release.