Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1054495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:24:58+00:00 2026-05-16T17:24:58+00:00

Am a bit confused on how stack and heap are arranged in multithreaded processes:

  • 0

Am a bit confused on how stack and heap are arranged in multithreaded processes:

  1. Each thread has its own private stack.
  2. All threads share the heap
  3. When the program dynamically creates thread (ex: new Thread() in Java), the object is allocated on heap.

so does the heap contain memory for thread object, which means does heap contains stack (belonging to threads)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:24:59+00:00Added an answer on May 16, 2026 at 5:24 pm

    Its delibrately vague as we don;t want to constrain the implementers of the threading software.

    Each thread has its own private stack.

    As each thread executes a set of function independ from each other they need to store return addresses etc thus each needs its own stack.

    All threads share the heap

    That’s the easiest way to implement it. This also means that all the threads share a common chunk of memory so that each thread can communicate with other threads simply by modifying memory.

    When the program dynamically creates thread (ex: new Thread() in Java), the object is allocated on heap.

    The stack you mention in question 1. We need to reserve memory for it. So we allocate a chunk of the heap give it to the thread and say use this chunk of memory to implement your stack. (Not saying that it does it this way but that is a simple technique for doing it).

    so does the heap contain memory for thread object, which means does heap contains stack (belonging to threads) ?

    In a single threaded program there is room to implement the stack as chunks of the heap. The concept of stack and heap being separate and growing towards each other is just that; a concept. It is undefined how either are implemented and their is no reason that we can not implement the stack inside the heap. See this question for more information: stack growth direction

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a bit confused about the size of my App! The folder and all
I am alittle bit confused on topic of allocating objects on heap vs allocating
So I'm horribly confused by this error, other threads on Stack Overflow mention I
I'm little bit confused with one thing about memory stack. From what I know
I'm a bit confused why I can't initialize a getter this way: @synthesize stack
Bit confused here, I have an on-demand instance but do I get charged even
I am a bit confused about the 'rules' of when a TextView element displays
I am bit confused, as my title mentioned, Is id in Objective C is
Perhaps I'm a bit confused about when to use the waitForPageToLoad command, but what
I'm a bit confused by the Lucene.NET API, but, it may just be a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.