Java Thread stack memory allocation and management

I am curious to know how java stack threads are managed. Since there is one stack per thread that allocated on a segment of memory specifically requested from the operating system (see Here).

  1. When this memory is released? by garbage collector or by native thread?
  2. How java process signals to the OS that this memory segment isn't used any more?
  3. How this memory affected is the thread was terminated but his corresponding object still has references from other live object?

Answers


When this memory is released? by garbage collector or by native thread?

None. It is released by the OS...

How java process signals to the OS that this memory segment isn't used any more?

... when the thread terminates. The JVM does nothing here but use the native thread API which in turns uses the OS primitives. And...

How this memory affected is the thread was terminated but his corresponding object still has references from other live object?

... this on the other hand is the role of the JVM; of the GC specifically.

Note that creating a Thread (or Runnable or Callable) does not actually create a thread at the OS level; you have to run it for that (using .start() for a Thread, etc etc).


Need Your Help

Storing page code on a JSP session

jsp session navigation preferences

I have an options menu, over a jsp page, on which users explore items, that have sub-items, that have sub-sub-items and so on. Items are collapsable, so the user can see the hierarchy of the items he

Check if browser accepts cookies

c# asp.net browser cookies

Is there a way that I can check if the browser will allow cookies.