Precise segmentation of lung field is a crucial step in chest radiographic computer-aided diagnosis system. With the development of deep learning, fully convolutional network based models for lung field segmentation have achieved great effect but are poor at accurate identification of the boundary and preserving lung field consistency. To solve this problem, this paper proposed a lung segmentation algorithm based on non-local attention and multi-task learning. Firstly, an encoder-decoder convolutional network based on residual connection was used to extract multi-scale context and predict the boundary of lung. Secondly, a non-local attention mechanism to capture the long-range dependencies between pixels in the boundary regions and global context was proposed to enrich feature of inconsistent region. Thirdly, a multi-task learning to predict lung field based on the enriched feature was conducted. Finally, experiments to evaluate this algorithm were performed on JSRT and Montgomery dataset. The maximum improvement of Dice coefficient and accuracy were 1.99% and 2.27%, respectively, comparing with other representative algorithms. Results show that by enhancing the attention of boundary, this algorithm can improve the accuracy and reduce false segmentation.