  We show a unified second-order scheme for constructing simple, robust and
accurate algorithms for typical thermostats for configurational sampling for
the canonical ensemble. When Langevin dynamics is used, the scheme leads to the
BAOAB algorithm that has been recently investigated. We show that the scheme is
also useful for other types of thermostat, such as the Andersen thermostat and
Nos\'e-Hoover chain. Two 1-dimensional models and three typical realistic
molecular systems that range from the gas phase, clusters, to the condensed
phase are used in numerical examples for demonstration. Accuracy may be
increased by an order of magnitude for estimating coordinate-dependent
properties in molecular dynamics (when the same time interval is used),
irrespective of which type of thermostat is applied. The scheme is especially
useful for path integral molecular dynamics, because it consistently improves
the efficiency for evaluating all thermodynamic properties for any type of
thermostat.
