package com.topsun.posclient.common.core;
/**
* @author ysc
*/
public class BarcodeProducter {
private boolean quit;
private Thread thread;
private ScanBarcodeService scanBarcodeService;
public BarcodeProducter(){
scanBarcodeService=new ScanBarcodeService();
}
/**
*/
public void startProduct() {
if(thread!=null && thread.isAlive()){
return;
}
thread=new Thread() {
@Override
public void run() {
while (!quit) {
try {
Thread.sleep(Long.MAX_VALUE);
} catch (Exception e) {
quit=true;
}
}
scanBarcodeService.stopScanBarcodeService();
System.exit(0);
}
};
thread.start();
new Thread() {
@Override
public void run() {
scanBarcodeService.startScanBarcodeService();
}
}.start();
}
/**
*/
public void stopProduct(){
if(thread!=null){
thread.interrupt();
}
}
}