summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/monitor.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/monitor.rb b/lib/monitor.rb
index 2a59fa7cc0..999795c3d0 100644
--- a/lib/monitor.rb
+++ b/lib/monitor.rb
@@ -255,9 +255,13 @@ module MonitorMixin
# Initializes the MonitorMixin after being included in a class or when an
# object has been extended with the MonitorMixin
def mon_initialize
+ if defined?(@mon_mutex) && @mon_mutex_owner_object_id == object_id
+ raise ThreadError, "already initialized"
+ end
+ @mon_mutex = Thread::Mutex.new
+ @mon_mutex_owner_object_id = object_id
@mon_owner = nil
@mon_count = 0
- @mon_mutex = Thread::Mutex.new
end
def mon_check_owner