package com.android.testbtspp2_1;

import java.util.Random;

import android.os.Handler;

public class RandomNumberThread extends Thread {
	private byte[] oriData;
	private Random r;
	private Handler mhandler;
	private boolean isStop;
	private byte[]ch1,ch2,ch3,ch4;
	private int times;
	public RandomNumberThread(Handler hand){
		mhandler = hand;
		isStop = false;
		ch1 = new byte[2000];
		ch2 = new byte[2000];
		ch3 = new byte[2000];
		ch4 = new byte[2000];
	}
	public void run(){
		times = r.nextInt(1500);
		if(times>128){
		    for(int i=0;i<times && !isStop;i++){//65536=128sec
		    	ch1[i] = (byte) r.nextInt(256);
		    	ch2[i] = (byte) r.nextInt(256);
		    	ch3[i] = (byte) r.nextInt(256);
		    	ch4[i] = (byte) r.nextInt(256);
		      if(i%128==0)
				try {
					this.sleep(1000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
		    }
		}
	}
	public void setIsStop(boolean newTag){
		isStop = true;
	}
    

}
