当在使用junit单元测试时,如果再主线程中加入了子线程,当主线程结束时,子线程也随着结束。
package com.thread.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.entity.Student;
import com.thread.dao.IStudentDao;
@Service
public class StudentServiceImpl implements IStudentService {
@Autowired
private IStudentDao dao;
public void setDao(IStudentDao dao) {
this.dao = dao;
}
@Override
//@Transactional(propagation = Propagation.NESTED, timeout = 1000, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class, noRollbackFor = CustomRuntimeException.class)
// @Transactional (propagation = Propagation.REQUIRE