Trying to design thread safe class
-
No, that is not thread-safe. This is :
public static int X1{} { lock(locker) return x1; }
Best, John
-
Please look at my final version and tell me what you think: http://codepad.org/T3D6uabs[^]
yes, it's threadsafe
-- LogWizard - Log Viewing can be a joy!
-
yes, it's threadsafe
-- LogWizard - Log Viewing can be a joy!
Thanks a lot, few more questions, and I would appreciate if you can help: - if I add more variables other than x1 and x2 but I maintain same style in accessing and initializing them will it affect thread safety? will it affect performance? (probably). Do you know more performance friendly way to solve the problem my class solves?
-
Thanks a lot, few more questions, and I would appreciate if you can help: - if I add more variables other than x1 and x2 but I maintain same style in accessing and initializing them will it affect thread safety? will it affect performance? (probably). Do you know more performance friendly way to solve the problem my class solves?
1. if you add more variables in the same manner, yes 2. will it affect performance? don't worry about that, performance will be the same. And on the init()/deinit() - the "decrease" won't be noticeable. 3. Your class is fine Best, John
-- LogWizard - Log Viewing can be a joy!
-
1. if you add more variables in the same manner, yes 2. will it affect performance? don't worry about that, performance will be the same. And on the init()/deinit() - the "decrease" won't be noticeable. 3. Your class is fine Best, John
-- LogWizard - Log Viewing can be a joy!
-
1. if you add more variables in the same manner, yes 2. will it affect performance? don't worry about that, performance will be the same. And on the init()/deinit() - the "decrease" won't be noticeable. 3. Your class is fine Best, John
-- LogWizard - Log Viewing can be a joy!
Great job supporting this OP, John. I am voting your replies up. cheers, Bill
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
-
Great job supporting this OP, John. I am voting your replies up. cheers, Bill
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
Thanks :-O
-- LogWizard - Log Viewing can be a joy!
-
Thanks a lot!!! So you are saying if I add more properties in same manner, it won't be problem?
Yup, that's exactly what I'm saying :) Best, John
-- LogWizard - Log Viewing can be a joy!
-
Yup, that's exactly what I'm saying :) Best, John
-- LogWizard - Log Viewing can be a joy!
-
Great job supporting this OP, John. I am voting your replies up. cheers, Bill
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
-
you're welcome Best, John
-- LogWizard - Log Viewing can be a joy!