The collective behavior of an ensemble of multimode stochastic oscillators is investigated. The oscillators are pulse coupled; they are able to emit pulses and to detect the pulses emitted by the others. As a function of the output intensity in the system they can operate in different modes having different pulsing periods. The system is designed to optimize the output intensity around a fixed f* output threshold. In order to do so a simple dynamics is considered. Whenever the total output intensity in the system is lower than f*, a mode with a higher interpulse period is chosen. If the light intensity in the system is higher than f*, a mode with a lower interpulse period is selected. As a side effect of this simple optimization rule, for a given f* interval a nontrivial synchronization of the oscillators is observed. The synchronization level is studied by computer simulations, investigating the influence of model parameters (number of modes, stochasticity of the oscillators, the f* threshold value, and interaction topology). An experimental realization of this system is also considered; an ensemble of electronic oscillators communicating with light pulses was constructed and studied. The experimental system behaves in many ways similar to the theoretically considered multimode stochastic oscillator ensemble.