Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can Method Variables be shared between users?  RSS feed

 
Ranch Hand
Posts: 35
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can method variables be shared between users?


I was asked this on an interview and I didn't know what to make of it. THANKS!
 
Bartender
Posts: 322
24
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jacob,

I don't believe that would be possible for two reasons:

  • Java doesn't support static method variables
  • In a multi-threaded environment, method variables allocate on a thread's method-call stack. Therefore, each thread gets it's own copy of the method variables


  • Cheers!
    Chris
     
    Author and ninkuma
    Marshal
    Posts: 66528
    160
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I'm not even sure what "shared between users" is supposed to mean.
     
    Bartender
    Posts: 10575
    66
    Eclipse IDE Hibernate Ubuntu
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Jacob Draper wrote:I was asked this on an interview and I didn't know what to make of it.


    Then I suggest that the lesson for next time is probably to ask.

    Interviewers ask some awfully stupid questions; some of which are "smart stupid" - ie, they want to find out how much you know by being deliberately vague - and others which are just plain ridiculous. This sounds to me like the latter, but I'm only going by what I see.

    If you're unsure about something, the best policy is usually to ask for clarification - and the best place to get that is from the interviewer. We can only offer hindsight.

    And if your interviewer regards such a question as a sign of "weakness", then you probably didn't want the job in the first place.
    You could also tell them about the "Dunning-Kruger" effect.

    Winston
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!