US stock market closes Thursday with gains for 2nd day