Lockable variables

I was just thinking and I had an idea for a concept, but I wanted to get some input from other people before putting it to use.

Concept: lockable variables. You set a locked flag and then you can set it’s value.

[icode]LockedVariable.java[/icode]

public class LockedVariable<T> {

	private T value;
	
	private boolean locked = false;
	
	public LockedVariable() {
		
	}
	
	public LockedVariable(T value) {
		this.value = value;
	}
	
	public void lock() {
		locked = true;
	}
	
	public void unlock() {
		locked = false;
	}
	
	public void setValue(T t) {
		if (!locked) value = t;
	}
	
	public T getValue() {
		return value;
	}
	
}

Any feedback on whether this idea is worth putting to practice would be appreciated :slight_smile:

CopyableCougar4