B
beginwithl
hi
1) “Aborting or suspending an active thread is generally considered a
bad idea. When you do so, there is a chance (however small) that a
thread could “leak” its workload when disturbed or terminated.”
What is considered a workload? And why could suspended/aborted thread
leak?
2)
a) As far as I understand, even if you give a thread T1 highest
priority, CLR won’t necessarily instruct thread scheduler to give it
such priority? How will we know whether CLR decided not to give T1
highest priority?
b) But even if CLR does instruct thread scheduler to give it highest
priority, but at some point thread scheduler is preoccupied with a
given task and thus decides to give more time to other thread with
lower priority, will it in that case also change the level of T1’s
priority accordingly, or will it leave T1’s priority set to max and
just threat it as being of lower priority?
3) If we, inside primary thread T0, use a delegate to invoke some
method M1 in an asynchronously manner, then M1 will be called on a
separate thread T1. When M1 is finished, T1 can use AsyncCallback
delegate ( which in turn calls some method M2 ) to inform T0 when
the task is finished.
But I’d argue that AsyncCallback delegate instance doesn’t really
inform calling thread ( T0 in our example ) whether asynchronously
invoked method M1 is completed. All Asyncallback delegate does is
calling method M2 ( M2 is invoked inside thread T1 ). Perhaps
programmer can inside M2 implement some sort of mechanism, which
somehow informs T0 to stop whatever it is doing, because M1 has
completed. But for AsyncCallback delegate to really inform the
calling thread M1 has finished, it would have to invoke M2 inside T0,
which it doesn’t! Correct?
thank you
1) “Aborting or suspending an active thread is generally considered a
bad idea. When you do so, there is a chance (however small) that a
thread could “leak” its workload when disturbed or terminated.”
What is considered a workload? And why could suspended/aborted thread
leak?
2)
a) As far as I understand, even if you give a thread T1 highest
priority, CLR won’t necessarily instruct thread scheduler to give it
such priority? How will we know whether CLR decided not to give T1
highest priority?
b) But even if CLR does instruct thread scheduler to give it highest
priority, but at some point thread scheduler is preoccupied with a
given task and thus decides to give more time to other thread with
lower priority, will it in that case also change the level of T1’s
priority accordingly, or will it leave T1’s priority set to max and
just threat it as being of lower priority?
3) If we, inside primary thread T0, use a delegate to invoke some
method M1 in an asynchronously manner, then M1 will be called on a
separate thread T1. When M1 is finished, T1 can use AsyncCallback
delegate ( which in turn calls some method M2 ) to inform T0 when
the task is finished.
But I’d argue that AsyncCallback delegate instance doesn’t really
inform calling thread ( T0 in our example ) whether asynchronously
invoked method M1 is completed. All Asyncallback delegate does is
calling method M2 ( M2 is invoked inside thread T1 ). Perhaps
programmer can inside M2 implement some sort of mechanism, which
somehow informs T0 to stop whatever it is doing, because M1 has
completed. But for AsyncCallback delegate to really inform the
calling thread M1 has finished, it would have to invoke M2 inside T0,
which it doesn’t! Correct?
thank you