• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic