Make sure that main thread run on it's own core alone
<p>I have a main thread which do some not-so-heavy-heavy work and also I'm creating worker threads which do very-heavy work. All documentation and examples shows how to create a number of hardware threads equal to <code>std::thread::hardware_concurrency()</code>. But since main thread already existed the number of threads becomes <code>std::thread::hardware_concurrency() + 1</code>. For example:</p>

<ul>
<li>my machine supports 2 hardware threads.</li>
<li>in main thread I'm creating this 2 threads and the total number of threads becomes 3.</li>
<li>a core with the main thread do it's job plus (probably) the worker job.</li>
</ul>

<p>Of course I don't want this because UI (which is done in main thread) becomes not responsive due to latency. What will happen if I create <code>std::thread::hardware_concurrency() - 1</code> thread? Will it guarantee that the main thread and only main thread is running on single core? How can I check it?</p>

<p>P.S.: I'm using some sort of pool - I start threads on the program start and stop on exit. During the execution all worker threads run infinite <code>while</code> loop.</p>