Are there any cases when it's preferable to use a plain old Thread object instead of one of the newer constructs?

前端 未结 10 1985
挽巷
挽巷 2021-01-30 01:45

I see a lot of people in blog posts and here on SO either avoiding or advising against the usage of the Thread class in recent versions of C# (and I mean of course

10条回答
  •  余生分开走
    2021-01-30 02:47

    It's not definitely obsolete.

    The problem with multithreaded apps is that they are very hard to get right (often indeterministic behavior, input, output and also internal state is important), so a programmer should push as much work as possible to framework/tools. Abstract it away. But, the mortal enemy of abstraction is performance.

    So my question is, are there any cases when it's necessary or useful to use a plain old Thread object instead of one of the above constructs?

    I'd go with Threads and locks only if there will be serious performance problems, high performance goals.

提交回复
热议问题