sentence: an example in java follows : class account -lcb- / / this is a monitor of an account long val = 0 ; object thislock = new object ( ) ; public void deposit ( const long x ) -lcb- lock ( thislock ) -lcb- / / only 1 thread at a time may execute this statement val + = x ; -rcb- -rcb- public void withdraw ( const long x ) -lcb- lock ( thislock ) -lcb- val - = x ; -rcb- -rcb- -rcb- the code lock ( this ) is a problem if the instance can be accessed publicly .