开发者

in ASP.Net, are long running static operations a bottleneck?

If a long running operation is defined in a frequently called static method, is it a bottleneck for other threads in an ASP.Net application trying to call the same method?

Does that only apply to methods with the "Synchronized" attribute>?

I've searched and ca开发者_如何转开发n't seem to find a definitive answer.


No, it's not going to block any other threads unless the method either acquires a common lock (e.g. due to the Synchronized attribute) or calls a synchronized method itself.

As Darin says, you could potentially exhaust the thread pool, but I don't think that's what your question was worrying about. To be absolutely clear, you can definitely have two threads executing the same static method at the same time, if there isn't any synchronization involved.


This will depend on when you call this static method. If you call it directly from the code behind (for example in Page_Load or some button click) you will monopolize the thread serving the request. Threads serving requests are drawn from a thread pool. If slow operations are called on them (no matter if you call a static or instance method) your application servicing capabilities will suffer.

You could use asynchronous pages to improve performance if the operation is IO bound (database call, web service call, some network call in general).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜