public void tick()
    {
        for(Integer i = 0; i < Main.CPU_COUNT; ++i)
        {
            Integer waitingTime = waitingTimes.get(i);
            Process currentProcess = runningProcesses.get(i);
            if(waitingTime > 0)
            {
                // The CPU is currently waiting
                waitingTimes.set(i, --waitingTime);
                currentProcess.pause();
                if(waitingTime == 0)
                {
                    System.out.printf("[time %dms] Process %d created (requires %dms CPU time, priority is %d)\n", time, currentProcess.getId(), currentProcess.getTimeRemaining(), currentProcess.getPriority());
                }
                continue;
            }

            if(currentProcess == null)
            {
                // This only happens if the CPU is idle
            }
            else
            {
                currentProcess.run();
                // If this process has terminated
                if(currentProcess.getTimeRemaining() == 0)
                {
                    // True turnaround time is the time taken to run process and the total time waiting
                    currentProcess.setTimeTotal();

                    // Display some information about it
                    System.out.printf("[time %dms] Process %d completed its CPU burst (turnaround time %dms, initial wait time %dms, total wait time %dms)\n", time, currentProcess.getId(), currentProcess.getTimeTotal(), currentProcess.getTimeInitiallyWaiting(), currentProcess.getTimeWaiting());

                    // Remove the process from the set of running
                    runningProcesses.set(i, null);

                    // Add it to the set of finished
                    finishedProcesses.add(currentProcess);
                }
            }

            Process nextProcess = getNextProcess(i);
            if(nextProcess == null)
            {
                // We're done for now, there are no more processes, CPU is idle
                continue;
            }

            if(nextProcess != currentProcess)
            {
                if(currentProcess != null)
                {
                    // A process was just running, we need a context switch
                    System.out.printf("[time %dms] Context switch (swapping out process %d for process %d in CPU %s)\n", time, currentProcess.getId(), nextProcess.getId(), Character.toString((char) (65 + i)));
                    waitingTimes.set(i, Main.CONTEXT_SWITCH);
                }
                else
                {
                    // This is the first process so start it now
                    System.out.printf("[time %dms] Process %d created (requires %dms CPU time, priority is %d)\n", time, nextProcess.getId(), nextProcess.getTimeRemaining(), nextProcess.getPriority());
                }
                runningProcesses.set(i, nextProcess);
            }
        }

        for(Process process : waitingProcesses)
        {
            process.pause();
        }

        time++;
    }