package ca.polymtl.inf4410.tp2.server;

import java.rmi.RemoteException;
import ca.polymtl.inf4410.tp2.shared.CalculousServerInterface;
import ca.polymtl.inf4410.tp2.shared.OverloadedServerException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.Semaphore;


public class UnsafeRepartitorThread extends SafeRepartitorThread {

       
        // WE SHOULD ADD UNSAFE LOGIC HERE

        UnsafeRepartitorThread(Repartitor repart, CalculousServerInterface server, ArrayList<String> calculations, Semaphore calculationsSemaphore, int[] globalResult, Semaphore globalResultLock) {
                super(repart, server, calculations, calculationsSemaphore, globalResult, globalResultLock);
        }

	@Override
	public void run() {
                int res = 0;
                int operationNumber = 0;
		while (repartitor.threadsShouldContinue()){                                			
                        try {
                                operationNumber = threadedPickingCalculous();
                                res = calculate(serverStub, calculousOwnedByThread);
                                threadedAddingResult(res, operationNumber);
                                handleUnderload();
                        }
                        catch(NoMoreWorkException | InterruptedException | RemoteException e){}
                        catch (OverloadedServerException ex) {
                            try {
                                pushBackThreadCalculousToCalculous();
                            } catch (InterruptedException ex1) {}
                            handleOverload();
                        }
		}
	}
        
                     
}
@@ -754,24 +754,26 @@
 oid run() %7B%0A
+//
             
@@ -789,16 +789,18 @@
 es = 0;%0A
+//
         
@@ -832,16 +832,18 @@
 er = 0;%0A
+//
 %09%09while 
@@ -915,16 +915,18 @@
     %09%09%09%0A
+//
         
@@ -939,32 +939,34 @@
           try %7B%0A
+//
                 
@@ -1019,32 +1019,34 @@
 ingCalculous();%0A
+//
                 
@@ -1114,16 +1114,18 @@
 hread);%0A
+//
         
@@ -1192,16 +1192,18 @@
 umber);%0A
+//
         
@@ -1237,32 +1237,34 @@
 dleUnderload();%0A
+//
                 
@@ -1273,16 +1273,18 @@
       %7D%0A
+//
         
@@ -1371,16 +1371,18 @@
 on e)%7B%7D%0A
+//
         
@@ -1432,24 +1432,26 @@
 ption ex) %7B%0A
+//
             
@@ -1472,16 +1472,18 @@
   try %7B%0A
+//
         
@@ -1540,24 +1540,26 @@
 alculous();%0A
+//
             
@@ -1612,16 +1612,18 @@
 ex1) %7B%7D%0A
+//
         
@@ -1660,16 +1660,18 @@
 load();%0A
+//
         
@@ -1688,16 +1688,18 @@
       %7D%0A
+//
 %09%09%7D%0A%09%7D%0A 

comment safelogic in unsafe thread