开发者

Will thread.join() block other clients also?

In an asp.net web application, say everytime the user makes the request, and the page loads, a thread is fired off that uses thread.join() to block exec开发者_运维百科ution until it's finished.

Say this thread takes 10 seconds to complete.

Does this mean that if 5 totally seperate users make a request to this page, mere miliseconds after the last, does this mean the last user is going to wait 50 seconds to finish their request? Or is each client request threaded?


Typically, other users will not be blocked.

However, the call to Join ties up a thread pool thread. Once all threads are in use, subsequent requests must wait for a thread to become available.


Join itself just blocks the current thread until the thread you want to join finishes executing, so normally calling it only blocks the current request, not other users.

If for some ungodly reason you're calling join within a lock on a shared resource, that would block other users trying to access the shared resource.


It sounds like you are describing a scenario where every user request creates a new Thread which executes a task during Page Load. Page Load does a few operations and then calls thatThread.Join. If so then ...

How much time it will take 5 users simultaneously accessing the page depends a lot on what thatThread is doing. In particular if the separately spawned threads interact with each other. For example if they took a lock on a shared resource for a portion of the execution then yes, simultaneous requests will impact performance. If the lock is held for the duration of the operation then yes it could have a linear impact on performance.

On the other hand if they do completely independent tasks then they won't have a linear impact on performance.

If you could provide more details on what the thread was doing we could better answer the question.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜