Constructing sensing barriers using wireless sensor networks has important applications in military operations and homeland security. The goal of forming a sensing barrier is to detect intruders attempting to cross the network. Early studies often assume that sensors remain static once deployed. We note that barrier gaps may occur at deployment if sensors are deployed at random. Barrier gaps may also occur in an existing barrier if some sensors used to form the barrier start malfunctioning or run out of power. We present an efficient solution to solve this problem. In particular, we devise an efficient algorithm to find sensing gaps and relocate mobile sensors to form a new barrier while balancing the energy consumption among mobile sensors. We also investigate the related design issues and performance tradeoffs. Simulation results show that our algorithms can effectively improve the barrier coverage of a wireless sensor network under a wide range of deployment parameters. These result...