The blinking one is the prompt that is ready for input (because it's in the foreground).
It's a visual cue so you know which command box your input will go to.
More info from Wikipedia:
In most command-line interfaces or text editors, the text cursor or caret navigation, is an underscore, a solid rectangle, or a vertical line, which may be flashing or steady, indicating where text will be placed when entered (the insertion point).
and
The blinking of the text cursor is usually temporarily suspended when it is being moved; otherwise, the cursor may change position when it is not visible, making its location difficult to follow.
As to "How" it's implemented, that would depend on the command line interface being used, and will probably vary from vendor to vendor, and many of those vendors are closed-source.
Often the cursor appearance is also affected/controlled by the video adapter, but generally only in true video text modes.
If I were to implement my own, I'd image a timer that toggles the cursor's visibility state would be used, and that timer would be suspended when the window loses focus (perhaps also setting the state in not-visible), and started again when focus returns. But that's simplifying the crap out of it. ;)