Add synchronization to dpturnbull's code

This commit is contained in:
Bradlee Speice 2012-11-17 11:37:33 -05:00
parent afc1ffcf54
commit e6e1a8b634
2 changed files with 11 additions and 8 deletions

View File

@ -275,9 +275,11 @@ class FirstFit implements baseAlgorithm
jobSize=size; jobSize=size;
startLoc=start; startLoc=start;
for(int fillCount=startLoc; fillCount<jobSize+startLoc; fillCount++) synchronized(memory){
{ for(int fillCount=startLoc; fillCount<jobSize+startLoc; fillCount++)
memory[fillCount]=jobId; {
memory[fillCount]=jobId;
}
} }
} }

View File

@ -62,7 +62,7 @@ class NextFit implements baseAlgorithm
if(jobSize>memSize) if(jobSize>memSize)
{ {
System.out.println("\n\n*********************************************************"+ System.out.println("\n\n*********************************************************"+
" THIS JOB IS TO LARGE TO FIT INTO MEMORY"+ " THIS JOB IS TOO LARGE TO FIT INTO MEMORY"+
"*********************************************************"); "*********************************************************");
System.exit(0); System.exit(0);
} }
@ -293,10 +293,11 @@ class NextFit implements baseAlgorithm
jobId=job; jobId=job;
jobSize=size; jobSize=size;
startLoc=start; startLoc=start;
synchronized(memory){
for(int fillCount=startLoc; fillCount<jobSize+startLoc; fillCount++) for(int fillCount=startLoc; fillCount<jobSize+startLoc; fillCount++)
{ {
memory[fillCount]=jobId; memory[fillCount]=jobId;
}
} }
} }