Jump to content
  • Advertisement
Sign in to follow this  
plywood

Effects of Multi-Threading on Static Methods

This topic is 3694 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Let's say that a server-side object (C#) called Widget had one public method, exec(String), and several public static methods: String foo1(String) String foo2(String) String foo3(String) The idea here is to enable the Widget object to work in two different ways: (1) At the user's request, they can just pass a String to the exec() method where it is computed a certain way. (2) Or, they can choose to have their String processed differently without having to instantiate a Widget object via the static methods. Now let's say we want to make Widget massively-multithreaded, such that thousands of users could be connected to the server and using the same multi-threaded Widget object (residing server-side)... How does .NET handle multithreading when an object is set up to be multi-threaded but has static methods that are publicly-accessible? Is there a performance impact, or is there no difference at all as would be the case if those methods were non-static? Pros/cons to using statics (with relation to multi-threading)?

Share this post


Link to post
Share on other sites
Advertisement
To my knowledge, there's no tangible difference between foo.bar() and bar(foo);

In general, static methods that are not pure (do stuff to anything beyond locals and parameters) are very difficult to work with in a multithreaded enviornment.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!