I've run into a problem recently, it's not overly harmful - only if I'm AFKing. Occasionally, it will just pause, as if I'd hit Esc. It's happened a couple of time during an AFK session, but sometimes it'll do it when I'm actually playing, like mining or building something.
It doesn't happen regularly, like every 20 minutes or so; sometimes it won't happen for hours at a time, then twice in the space of 30 minutes. As far as I can tell, this is Minecraft doing this - my PC is not switching processes, or opening other apps or anything like that.
Edit: after applying the suggestion to use the F3+P command, the game no longer pauses.
But, I haven't seen the window lose focus, and the game will still occasionally, randomly "stop". Like, if I was moving, while holding down the movement keys, my character will simply stop moving. I can move the mouse to look around still, and click (use an item, etc), but I need to let go and press the movement key again in order to start moving again. This also affects my AFK fish farm for example - at random points, when I am holding down the right mouse button to "use" my rod, that input would be dropped.