Do you need to share a single keyboard and mouse as well? If so a KVM switch would be perfect. Otherwise, if the monitor has two different inputs (VGA, DVI etc) plug each input into different computers and just switch inputs through the monitor's menu.
i have two computers (my macbook and my PC) connected to the same monitor, but when one of them sleeps it will switch over to the other input and ill have to go through the long-ass menus to switch it back. Gets effing annoying tbh with you.
i dont plug them both in enough to warrant gettting a decent KVM, but i'd recommend it if you want to permanently use the same monitor.