0

I have read many topics regarding java memory initialization. I am not still not clear about static method initialization.

public class Abc
{
    public static int test(String abc,Date d,Employee e){
    --Some internal processing--
    return 100;
    }
}

1.Suppose if two threads are calling method test(Abc.test(--some data--)) will this two threads have separate stack or share same stack.

2.Will Static methods and constants(static final) consume more memory.

I need answer for this questions with clear explanation. If some one can give me memory structure for stack that will be good enough for my understanding.

Thanks you for all your answers.

  • 1
    Each thread has its own stack regardless of what methods it calls. You might want to look up "call stack" in Wikipedia to get more understanding of how the stack works. – ajb Jul 11 '17 at 04:36
  • 1
    Threads always have their own stack. Static constants consume a fixed amount of memory. Not sure what you mean by "more memory". In reference to what? – shmosel Jul 11 '17 at 05:14
  • Will there be any disadvantages of fixed constants. –  Jul 11 '17 at 06:46
  • 1
    Disadvantages over what? – shmosel Jul 11 '17 at 06:51
  • Memory usage..Because they alive all the time right until jvm is shutdown. –  Jul 11 '17 at 07:00
  • Disadvantage implies there might be an advantageous alternative. You're not explaining what that is. – shmosel Jul 11 '17 at 07:27

0 Answers0