Thread-safe profiling