0

I have an object: QHash<long, QMap<long, QList<long>>> hash; During initialization, I add keys in the main thread, where each key corresponds to the ID of a worker thread on a one-to-one basis. Then, when starting multiple threads, each thread reads the value corresponding to its own key, which is a QMap<long, QList<long>>, and then performs read and write operations on this QMap. In this scenario, will there be multi-thread competition issues?

My program always crashes after operating on the QMap, and I wonder if it's related to this issue.

asked Sep 2, 2025 at 2:20
1
  • You could show your code. That would eliminate some of the guess work for us of figuring out why your program crashes. Generally speaking it's thread-safe to have multiple readers and 0 writers. But sometimes it's not obvious where writing is occurring. It's not always clear if reading is a completely passive operation. Probably best to provide a minimal reproducible example Commented Sep 2, 2025 at 15:47

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.