Groups | Blog | Home
all groups > dotnet distributed apps > march 2004 >

dotnet distributed apps : Singleton Question Threading Question


C Newby
3/19/2004 3:37:52 PM
Suppose i have a remote singelton such as

class MySingelton{

...

public Int32 GetSum( Int32 X, Int32 Y ){
Int32 sum = X + Y;
return sum;
}

}


Now suppose i have two requests (threads) for this method that happen in the
following order:

Thread A enters with GetSum( 1, 1 )
-> The local value sum is set to 2
-> Thread B enters with GetSum( 2, 2 )
-> The local value sum is set to 4
-> Thread A is returned 4 ???


Is this correct? Or does each thread get its own version of the method call
and its values? I'm a little confused ... :)


TIA//

Mickey Williams
3/19/2004 4:10:11 PM
Sum is local to the method stack, so each caller gets its own copy.

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com


[quoted text, click to view]

C Newby
3/25/2004 11:05:35 AM
Cool thanks a bunch ... i was hoping that was the answer :)

[quoted text, click to view]

AddThis Social Bookmark Button