NShiftKey-Rule-Guide logo NShiftKey-Rule-Guide

1. Vulnerability Description

2. Vulnerability Countermeasure

3. Sample Code

...
public class Calculator {
	private int memory;
	
	public int getMemory(){
		return memory;
	}
	
	public void setMemory(int memory){
		this.memory = memory;
		try{
			Thread.sleep(2000);
		}catch(InterruptedException e){}
		
		System.out.println(Thread.currentThread().getName() + "": "" + this.memory);
	}
}
...
...
public class Calculator {
	private int memory;
	
	public int getMemory(){
		return memory;
	}
	
	public synchronized void setMemory(int memory){
		this.memory = memory;
		try{
			Thread.sleep(2000);
		}catch(InterruptedException e){}
		
		System.out.println(Thread.currentThread().getName() + "": "" + this.memory);
	}
}
...