I recently started to learn Java programming and we just reach the Java Threads topic.
What I’m trying to understand is, lets say I have a Thread object which creates an instance of Object cat inside its run() method, as far as I learned (you are more than welcome to correct me if I’m wrong) the reference variable cat should be held in the heap (making it visible for all the “living” threads). However what I’m trying to understand is what kind of data is stored on the the thread’s “private” stack w.r.t this Object cat.
I recently started to learn Java programming and we just reach the Java Threads
Share
The cat reference (pointer) will be in the thread stack, the cat object will be in the heap.
You can check this link if you want to learn more:
http://www.javaworld.com/javaworld/jw-06-2012/120618-jw-archive-under-the-hood-threads-and-shared-data.html