Hello,
assume some multithreaded application, thread1 starts and finishes, then thread2 starts --- how is the possibility that these two threads will have the same object_id? On what it depends?
Thanks,
P.
Hello,
assume some multithreaded application, thread1 starts and finishes, then thread2 starts --- how is the possibility that these two threads will have the same object_id? On what it depends?
Thanks,
P.
Pavel Smerk wrote:
Hello,
assume some multithreaded application, thread1 starts and finishes, then thread2 starts --- how is the possibility that these two threads will have the same object_id? On what it depends?
If the first thread has stopped and been garbage collected, its object_id will be available for reuse, and it is perfectly possible for another thread to get it assigned on creation.
--
Alex
interesting question!
harp:~ > cat a.rb
h = {}
loop{ tid = Thread.new{}.object_id; (warn h.size.to_s and h.delete(tid)) if h[tid]; h[tid] = true }
harp:~ > ruby a.rb 2>&1|head
4344
5428
6510
looks like they recycle every few thousand threads - depending on how long the
threads run of course.
cheers.
-a
On Sat, 26 Aug 2006, Pavel Smerk wrote:
Hello,
assume some multithreaded application, thread1 starts and finishes, then thread2 starts --- how is the possibility that these two threads will have the same object_id? On what it depends?
Thanks,
P.
--
to foster inner awareness, introspection, and reasoning is more efficient than
meditation and prayer.
- h.h. the 14th dalai lama
Treat it as undefined. No two objects live at the same time will have
the same object id. That is the only guarantee.
Pavel Smerk wrote:
Hello,
assume some multithreaded application, thread1 starts and finishes, then
thread2 starts --- how is the possibility that these two threads will
have the same object_id? On what it depends?Thanks,
P.