I might try Synergy Besides that there's no other easy way? USBC to Display Port works?
Neither of your iMacs has a USB-C port....!
If you want to run two macs side-by-side, each using their own display, and operate them from a single keyboard and mouse, Synergy is exactly the tool for the job: just move the mouse off the side of one computer's screen and it pops up on the other one, and the keyboard input automatically follows it. There's also limited cut & paste support.
It just needs a network connection between the two macs - WiFi will do fine. Its about $20, or you can waste more than $20 worth of your time trying to find an old, free version or you can spend $20 on a cable that might not actually do what you want...
The other possibility for doing what you want is something like this:
https://www.amazon.co.uk/Plugable-One-Button-Swapping-Between-Computers/dp/B006Z0Q2SI
Basically, a KVM switch without the "V" part. You might consider that over Synergy if...
(1) Synergy doesn't play nicely with some software you're using - most likely games - or the slightest hint of extra latency gets you shot.
(2) You frequently need to use different boot options on the "remote" Mac (e.g. for alternate startup drives) before Synergy would have a chance to start
(3) You don't, for some reason, want the remote machine to always start the Synergy client on boot.
I've actually used one of those
together with Synergy for those reasons - but I was juggling 3-4 Macs/Linux/PCs and displays so I'd often need to re-configure Synergy or change boot options.
The other solutions suggested here...
"Screen sharing" would duplicate the screen of one Mac in a window on the screen of the other Mac. Yes, it lets you control one mac from the other, but its not what you want if the screens are side-by-side.
Connecting the second mac using "target display mode" - (
https://support.apple.com/en-us/HT204592) makes one Mac act as a second display for the other - doesn't actually solve your display switching problem so you might still need Synergy and/or the USB switch.
If you want to do that, you need to use the 2009 iMac as the "target display" and connect the 2011 iMac to it using a
miniDisplayPort-to-miniDisplayPort cable -
not a Thunderbolt cable. The 2009 doesn't have Thunderbolt and can't do anything with a Thunderbolt cable. The 2011 can only act as "target display" for other Thunderbolt Macs, but it can
output MiniDisplayPort.