assign each thread a cpu core

前端 未结 2 2009
梦毁少年i
梦毁少年i 2021-02-06 06:17

i have a windows service written in .net 4 which doing jobs periodically using Threads. the server has more than 20 cpu core.

i create 10 threads in my windows service.

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-06 06:35

    The OS already does precisely that for you. It doesn't guarantee that each thread will stay on the same core forever (and in nearly all cases, there's no need for that either), but it does try to keep as many cores busy as possible. Which means giving all available threads their own core as much as possible.

提交回复
热议问题