Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

1
  • I'm not very familiar with golang but if you have some sort of thread id, you could keep a dictionary of threads to held locks. If that works, you can surely build a simple function which abstracts the check to see if the current thread already has a lock on the mutex before attempting to acquire it. It kind of seems like that should be automatic though. That is, a thread trying to acquire a lock it already holds should be a no-op. Commented Jul 20, 2023 at 20:06