what happens when a static method(which uses static variables) is called by two instances of an object simultaneously. ..will the method execution be slower
Static method
Collapse
X
-
Originally posted by r035198xI'd like to hear your thoughts about it first.Comment
-
Originally posted by jyoheream not sure....actuall y i used it in my project.....wat i meant was that when one instance call to the static method is executing another call to that same method comes from another instance....the process becomes really slow....am i clear or sound stupid
I just wanted to hear your explanation first. Just to be sure, your application uses multithreading?Comment
-
Originally posted by r035198xNo your question doesn't sound stupid (not to me anyway).
I just wanted to hear your explanation first. Just to be sure, your application uses multithreading?Comment
-
Originally posted by jyohereno, it does not use multithreading. ...actually i create an object....it calls an instance method and this instance method calls a static method which uses static variables....an d this is repeated for say one more object.....ie. when the static method called by the previous object is executing....Comment
-
AAMOF, a static method call should be a bit faster than a (virtual) non-static
method call. The address of the static method is resolved during class loading
(equivalent to the ordinary static linking process), while a dynamically linked
(virtual) method call takes *two* memory fetches. Of course this takes next
to nothing timewise speaking.
kind regards,
Jos
ps. without seeing the actual methods noone can explain why things get slow.Comment
-
Originally posted by JosAHAAMOF, a static method call should be a bit faster than a (virtual) non-static
method call. The address of the static method is resolved during class loading
(equivalent to the ordinary static linking process), while a dynamically linked
(virtual) method call takes *two* memory fetches. Of course this takes next
to nothing timewise speaking.
kind regards,
Jos
ps. without seeing the actual methods noone can explain why things get slow.Comment
-
Originally posted by jyoherewat if two threads call the same static method
question. When multi-threading rears its ugly head you have to synchronize
certain blocks of code. I can't tell you anything more without knowing what
you're trying to design/implement.
kind regards,
JosComment
Comment