Boa tarde galera estou com um problema eu preciso fazer o Threshold em uma imagem com 1,2,4 e 8 Threads com uma eu ate consegui, mas nao consigo dividir pra fazer em 2,4 e 8. ai esta o codigo que eu fiz com 1. agora preciso fazer pra 2 4 e 8 e nao tenho ideia como fazer.
package proconc;
import java.awt.Color;
import java.util.concurrent.locks.*;
public class Exe extends Thread {
static int threshold;
int id;
static ReentrantLock r = new ReentrantLock();
private void umaThread() {
r.lock();
threshold = 200;
String filename = "/fishingboat.jpg";
Picture pic = new Picture(filename);
pic.show();
for (int i = 0; i < pic.width(); i++) {
for (int j = 0; j < pic.height(); j++) {
Color color = pic.get(i, j);
double lum = Luminance.lum(color);
if (lum <= threshold)
pic.set(i, j, Color.BLACK);
else
pic.set(i, j, Color.WHITE);
}
}
pic.show();
r.unlock();
}
public void run() {
long startTempo = System.currentTimeMillis();
umaThread();
long endTempo = System.currentTimeMillis();
System.out.println("Inicio: " + startTempo + " Fim: " + endTempo);
System.out.print((endTempo - startTempo) + "ms");
}
public static void main(String[] args) {
Exe exe = (new Exe());
exe.start();
}
}