added RAII example for lock and file access.