Protect access to "targets" in different threads to avoid crashes.