Added thread-safe timing function decorator