SchedulePstThread.java
936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.bsth.data.schedule.thread;
import java.util.LinkedList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.bsth.data.schedule.DayOfSchedule;
import com.bsth.entity.realcontrol.ScheduleRealInfo;
import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
/**
*
* @ClassName: SchedulePstThread
* @Description: TODO(班次异步持久化)
* @author PanZhao
* @date 2016年8月24日 上午1:47:05
*
*/
@Component
public class SchedulePstThread extends Thread{
@Autowired
ScheduleRealInfoRepository scheduleRepository;
@Override
public void run() {
LinkedList<ScheduleRealInfo> list = DayOfSchedule.pstBuffer;
ScheduleRealInfo schedule;
for (int i = 0; i < 1000; i++) {
schedule = list.poll();
if (null == schedule)
break;
scheduleRepository.save(schedule);
}
}
}