<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Abhyuday Pundir</title><link>https://abhyuday-fr.github.io/</link><description>Recent content on Abhyuday Pundir</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 05 Aug 2026 21:28:46 +0530</lastBuildDate><atom:link href="https://abhyuday-fr.github.io/index.xml" rel="self" type="application/rss+xml"/><item><title>Which Thread on Which CPU Core</title><link>https://abhyuday-fr.github.io/multithreading/which-thread-on-which-cpu-core/</link><pubDate>Wed, 05 Aug 2026 21:28:46 +0530</pubDate><guid>https://abhyuday-fr.github.io/multithreading/which-thread-on-which-cpu-core/</guid><description>&lt;p&gt;Let&amp;rsquo;s suppose your computer has &lt;strong&gt;4 CPU cores&lt;/strong&gt; and you decide to create &lt;strong&gt;2 threads&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Will they be created on the &lt;strong&gt;same core&lt;/strong&gt; or on &lt;strong&gt;different cores&lt;/strong&gt;?&lt;/p&gt;
&lt;p&gt;It sounds like a simple question, and you might already know the answer.&lt;/p&gt;
&lt;p&gt;But how do we actually &lt;strong&gt;verify&lt;/strong&gt; that answer with code?&lt;/p&gt;
&lt;h2 id="finding-the-number-of-cpu-cores"&gt;Finding the Number of CPU Cores&lt;/h2&gt;
&lt;p&gt;C++ provides &lt;code&gt;std::thread::hardware_concurrency()&lt;/code&gt;, which returns the number of hardware threads (logical CPUs) available to your program.&lt;/p&gt;</description></item></channel></rss>