private Integer m_writeLock = new Integer(0);
Vector ve;
Vector veSplus = new Vector(); //i don't know whether this vector should be global or not
//if you want to return value by this vector, please modify the constructor
public select (Vector ve /*, Vector veSplus */) {
this.ve = ve;
//this.veSplus = veSplus;
super("Select Thread");
}
public void run()//´úÈëÖÖȺ´óС
{
//Thread thread = new Thread();
int i;
Random r = new Random();
double pick=Math.random();//[0,1)Ëæ»úÊý
double sum=0;
oldfitness old=new oldfitness();
System.out.println("Before for loop " + System.currentTimeMillis());
for (i=0;(sum<pick)&&(i<200);i++)
{
//your code here....
}
System.out.println("end for loop " + System.currentTimeMillis());
int tmp_i=i-1;
ve.addElement(Integer.toString(tmp_i));
例如:
public double[] addin(){
//the following code just waste time. comment it!
//randomSolution ra = new randomSolution();
for (int i=0;i<45;i++)
{
vin[i] = this.randomRealNum();
}
return vin;
}
public class RandomTest
{
//Vector vin = new Vector();
double vin[];
private Random r;
DecimalFormat df;
public RandomTest () {
r = new Random();
vin = new double[200];
df = new DecimalFormat("#0.0");
}
public void testin(){
//the following line is just waste time!!!!!
//randomTest t = new randomTest();
for (int i=0;i<200;i++)
{
double aaa = ((double)r.nextInt() % ( 1 * 1000 + 1) ) / 1000;
//double aaa = (r.nextInt() % ( 1 * Math.pow(10,3) + 1) ) / Math.pow(10,3);
//vin.addElement(test);
vin[i] = Double.parseDouble(test);
//System.out.println((double)aaa);
}
}
public double test()
{
double d = r.nextInt(1000);
double s;
if (d>500)
{
s = 1;
}else{
s = -1;
}
return s;
}
public static void main (String argv[]) {
System.out.println(">>>>>>>>>" + System.currentTimeMillis());
RandomTest xTest = new RandomTest();
xTest.testin();
System.out.println("<<<<<<<<<" + System.currentTimeMillis());
}
}