Re: synchronizing primitive parms
Tuesday, March 19, 2002 02:22 AM
If you understand by primitive params, parameters of type int, bool, char, byte, etc. of a method, yes, they are thread safe, for a very simple reason: in Java, all parameters are passed by value, not by reference (when you pass an int, the int is copyed on stack, when you think you pass, for example, a Vector, which is an object, you really pass a reference to it, a reference passed by copying it on stack). So, the method has exclusive access to its primitive params, so even if you don't sync. it, it is thread safe to modify them and do whatever you want to do with them.