public void run() {
        Machine.interrupt().disable();
        ThreadedKernel.scheduler.setPriority(KThread.currentThread(), priority);
        // Make sure threadState exists
        ThreadQueue waitQueue =	ThreadedKernel.scheduler.newThreadQueue(true);
        waitQueue.waitForAccess(KThread.currentThread());
        if(lock1 != null)
            lock1.acquire();
        if(lock2 != null)
            lock2.acquire();
        Machine.interrupt().enable();

        KThread.currentThread().yield();

        for (int i=0; i<time; i++) {
            waitMS();
        
            if(lock1 != null)
                sharedTotal++;
            
            if(lock1 != null && i%5 == 0)   {
                System.out.println("Shared total is at " + sharedTotal);
            }
            KThread.currentThread().yield();
        }
        if(lock1 != null);
            System.out.println("Shared total is at " + sharedTotal);
        if(lock2 != null)
            lock2.release();
        if(lock1 != null)
            lock1.release();
    }