• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

SCJP5 Kathy sierra : Thread confusion

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am preparing for SCJP5 and Kathy sierra book. In that book, in thread chapter, I have a confusion as of following:
"A thread of execution is an individual process (a "lightweight" process) that has its own call stack. In Java,there is one thread per call stack´┐Żor, to think of it in reverse, one call stack per thread."

one thread per call stack-------- What does it actually signify? I can't understand this sentence. Can any one please help me to get clear idea?

Thanks
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have a forum specifically for the SCJP. I'll move this there for you...
 
Ranch Hand
Posts: 332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
.. means that, every thread has its own (one) callstack, and every callstack belongs to one thread..

it is 1:1 relationship

as the thread runs, every invoked method is put on stack (callstack), and when it returns, it is removed
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
.. means that, every thread has its own (one) callstack, and every callstack belongs to one thread..

it is 1:1 relationship

as the thread runs, every invoked method is put on stack (callstack), and when it returns, it is removed


Every callstack has exactly one thread instance associated with it,
but every Thread instance need not have a callstack.
 
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Each thread needs to have its own callstack because each thread needs to have its own set of local variables.

Kaydell
 
Pravin Jain
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is not for threads which are NEW or TERMINATED.
 
Kaydell Leavitt
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>> Each thread needs to have its own callstack because each thread needs to have its own set of local variables.

> That is not for threads which are NEW or TERMINATED.

That's a good point. I never really thought of that before.

That's what's great about the Java Ranch. I tried to help someone understand something and I learned something in the process.

Kaydell
 
I knew that guy would be trouble! Thanks tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic