vendredi 9 janvier 2015

integer not incrementing in inner loop


Vote count:

0




a quick description: In a multithreaded loop an integer is not incrementing in the inner loop while it does in the outer one.


my code:



public void run() {
if(maxH==actualmaxH)
actualmaxH--;
if(maxW==actualmaxW)
actualmaxW--;
for(;i<=actualmaxW; i++) {
for (; j <=actualmaxH; j++) {
Hit hit=world.hit(cam.rayFor(maxW,maxH,i,j));
Color col;

if(hit==null)
col = world.backgroundColor;
else
col = hit.geo.material.colorFor(hit, world, 0);

int rgb = ((int)(col.r*255)<< 16) | ((int)(col.g*255)<< 8) | ((int)(col.b*255));
raster.setDataElements(i, maxH - j - 1, model.getDataElements(rgb, null));
}

if(i%30==0) {
frame.update(g);
}
}
frame.update(g);
}


This bit of code is called from the constructor via "new Thread(this)"(this implements Runnable) and the constructor is called from another class with different i,j and actual.. the rest basically stays the same


Again, the problem is that in the inner loop the i gets incremented just fine, while in the inner loop its always 0(or of course the other starting numbers in the other threads)


I hope I was clear enough. Will answer questions to my code with pleasure if anything is unclear and hope for anyone to find a solution. Thanks anyway=)



asked 1 min ago







integer not incrementing in inner loop

Aucun commentaire:

Enregistrer un commentaire