We studied the phase-locking behavior of Josephson junctions in two-di
mensional arrays under microwave irradiation or coupled to a resonant
cavity. We are able to identify the phase-locked junctions by means of
spatially resolving measurements. We focus on the degree of coherence
in the arrays, changing from incoherent to coherent oscillations of t
he junctions when the microwave power is increased. We interpret our r
esults in terms of a second order phase transition to the phase-locked
state.