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

  • Home
  • SEARCH
  • 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 8480045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:11:54+00:00 2026-06-10T19:11:54+00:00

To my understanding, each thread usually gets only one stack (while all threads in

  • 0

To my understanding, each thread usually gets only one stack (while all threads in a process usually share a heap). I always thought that stack is used for storing the value of Program Counter(PC) when function call happens. But then I read somewhere that certain variable types such as integer or boolean are allocated onto the stack as well. Since values on stacks are managed in a strict FILO manner, how can these variables be retrieved at any time?

For example, after declaring int a, b, c;, I can do whatever I want to these variables in any order at any time within their scope. How is this done? Why isn’t value c on the top of the stack and therefore hiding values a, b?

  • 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-06-10T19:11:55+00:00Added an answer on June 10, 2026 at 7:11 pm

    The call stack is also used for local variables, and also for passing parameters into a function.

    You are right in that ‘Value types’ are passed on the stack, whereas reference types are allocated on the heap, but when a reference type is used as a parameter, a pointer to this heap location will be still passed on the stack.

    Although stacks are usually ‘perceived’ as LIFO buffers, there are also frame or base pointers associated with the call stack, which can be used to directly access memory above or below the current stack pointer. This is how functions can still have random access to parameters without changing the stack pointer.

    This diagram from Wikipedia may help visualize this, although note that many would argue that the stack should grow ‘downwards’.

    This blog post here explains Intel call stacks

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

Sidebar

Related Questions

My understanding is that each new thread in .Net allocates 1MB of stack space
I've got a multithreaded server (using POSIX threads), with one thread for each persistent
It's my understanding that GHC gives each thread a stack. Why is this necessary?
I have an application which runs some multi-threading process. In each thread I'm sharing
I've read akka documentation and can't produce clean understanding of thread interaction while using
In my understanding each applets are independent entities . Is it possible to have
From my understanding, each of these methods: get() and put() are atomic. But, when
My understanding is that threads in theory are executed in parallel. JVM decides; when
To my understanding a Thread.Sleep(0) force a context switch on the OS. I wanted
In one of Outlook add in, I have a worker thread that does some

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.