Skip to main content

How is thread memory released?

  • December 28, 2011
  • 1 reply
  • 0 views

[Migrated content. Thread originally posted on 22 December 2011]

I have an utility program, say A, with various entry points. To make these entry points available from any program without requiring to do an explicit call to A, i call A in a program that is surely run before all other programs and then never cancel A.

When a program, say B, is called in thread and tries to call an entry point of A it gives error, as the new thread doesn't have access to the main instance of A. So, in B i explicitly call A but i can't cancel it because B could also be called not in thread.

The question is, when a thread is stopped and its memory released, do all subprograms called in it are automatically cancelled or not?

Thank you in advance
Luca

1 reply

Stephen Hjerpe
  • Participating Frequently
  • 1100 replies
  • December 28, 2011

[Migrated content. Thread originally posted on 22 December 2011]

I have an utility program, say A, with various entry points. To make these entry points available from any program without requiring to do an explicit call to A, i call A in a program that is surely run before all other programs and then never cancel A.

When a program, say B, is called in thread and tries to call an entry point of A it gives error, as the new thread doesn't have access to the main instance of A. So, in B i explicitly call A but i can't cancel it because B could also be called not in thread.

The question is, when a thread is stopped and its memory released, do all subprograms called in it are automatically cancelled or not?

Thank you in advance
Luca
I believe the sub programs are automatically cancelled. To test you can Stop the B thread, call it again, and see if A is still in the state it was in before B stopped.