Great question. The electrodes don't "know" much about each other, except how much the other electrode is pushing or pulling the electrons in the wire. That information is conveyed by motion of the electrons in the wire. It determines whether the electrons flow from one electrode to the other. If the electrodes ae made of the same material, the pushes are equal. If they're different, there's a net flow as material is given off by one electrode and deposited on the other.
Mike W.
(published on 03/10/2017)