Variable threadcount

This commit is contained in:
darkress
2023-06-10 17:15:26 +02:00
parent 41242bf3ed
commit bf52cfa229

View File

@@ -94,41 +94,22 @@ class Main
final String HOSTNAME = args[2];
final int xOffset = Integer.parseInt(args[0]);
final int yOffset = Integer.parseInt(args[1]);
final String imageName = args[4];
int threadCount = Integer.parseInt(args[4]);
final String imageName = args[5];
// Read the PNG file
BufferedImage image = processImage(imageName);
String[] pixelArray = prepareArray(image, xOffset, yOffset);
ArrayList<Worker> workerList = new ArrayList<>();
Worker worker0 = new Worker(HOSTNAME, PORT, pixelArray);
Worker worker1 = new Worker(HOSTNAME, PORT, pixelArray);
Worker worker2 = new Worker(HOSTNAME, PORT, pixelArray);
Worker worker3 = new Worker(HOSTNAME, PORT, pixelArray);
Worker worker4 = new Worker(HOSTNAME, PORT, pixelArray);
Worker worker5 = new Worker(HOSTNAME, PORT, pixelArray);
Worker worker6 = new Worker(HOSTNAME, PORT, pixelArray);
Worker worker7 = new Worker(HOSTNAME, PORT, pixelArray);
worker0.start();
worker1.start();
worker2.start();
worker3.start();
worker4.start();
worker5.start();
worker6.start();
worker7.start();
/*try {
Socket socket = new Socket(HOSTNAME, PORT);
while(true) {
for(int i = 0; i < pixelArray.length; i++) {
byte[] payload = pixelArray[i].getBytes();
socket.getOutputStream().write(payload);
for(int i = 0; i < threadCount; i++)
{
workerList.add(new Worker(HOSTNAME, PORT, pixelArray));
}
for(int i = 0; i < threadCount; i++)
{
workerList.get(i).start();
}
} catch (IOException e) {
e.printStackTrace();
}*/
}
}