CPU scheduling
The conceptHow one CPU core runs hundreds of programs "at once"
It doesn't. A core runs one thread at a time. The operating system's scheduler hands the core to each ready thread in turn for a few milliseconds. The switching is so fast that everything seems to run at the same time.
The scheduler keeps a ready queue of threads that could run now. Threads waiting on disk, network or a keypress sit out until their event arrives. When the core frees up, it picks one and sets its time slice, or quantum.
The policy decides who goes next. First-come-first-served lets one long job block everyone. Shortest-job-first minimises the average wait but must know job lengths. Round robin gives each thread one slice, then sends it to the back.