S
Srubys
hiya
I’m reading a tutorial on suspending, resuming and stopping threads.
Its argument on why suspend(), resume() and stop() should not be used
is because if thread gets a lock on critical data structures and then
gets suspended, those locks may not be relinquished. Then tutorial
suggest we should instead use flag variables combined with wait() and
notify().
I don’t see how that makes anything safer. Just as you can get a lock
on critical data structure and then suspend a thread using suspend(),
you can also get a lock on critical data structure and set a flag in
such a way, that thread gets suspended ( via wait() ). In both cases
result would be the same. So how is the latter safer? It’s just a
different syntax, but same end result!
thank you
I’m reading a tutorial on suspending, resuming and stopping threads.
Its argument on why suspend(), resume() and stop() should not be used
is because if thread gets a lock on critical data structures and then
gets suspended, those locks may not be relinquished. Then tutorial
suggest we should instead use flag variables combined with wait() and
notify().
I don’t see how that makes anything safer. Just as you can get a lock
on critical data structure and then suspend a thread using suspend(),
you can also get a lock on critical data structure and set a flag in
such a way, that thread gets suspended ( via wait() ). In both cases
result would be the same. So how is the latter safer? It’s just a
different syntax, but same end result!
thank you