It sounds like what you are describing is actually program A running in the background. A process can still print to the terminal even if it is running in the background.
A bash example:
for ((i=0;i<=10;i++)); do
You can run this in the background, see its output popping up on your terminal. After the first output message, your cursor is moved off the prompt. You can then execute other commands in the foreground whilst
background_program is still executing:
./background_program & # '&' to put in background
This will give you something like:
sandbox@Dionysus:~$ ./background_program &
I did this in a gnome-terminal but I don't think the behavior is uncommon.
If you were to execute your program A in the foreground, you get exactly what @Stephen said, typeahead. The program is not executed as your command is loaded in the buffer and then interpreted after program A completes.