-1

The object in this case is a dictionary with some search methods. Only reading operations.

Kesarion
  • 2,808
  • 5
  • 31
  • 52
  • 4
    The Obvious Question: Is your object multi-thread-read-safe without locks? Thread-concurrency not withstanding, the answer to that question, and *your* question, is likely the same. – WhozCraig Nov 20 '12 at 12:29
  • Profile and see! Depends on the implementation of your "dictionary", but a normal one that doesn't make special allowance for multithreaded access won't impose any significant overhead. Be aware of special synchronised collections though; they may include some lock/release/wait overheads. – Rook Nov 20 '12 at 12:30
  • @WhozCraig: Most types are thread safe for *Only reading operations* (not a guarantee, but this seems to hold :) – David Rodríguez - dribeas Nov 20 '12 at 12:44
  • 1
    @DavidRodríguez-dribeas *All* standard lib containers are safe for this, for example, provided it is guaranteed not only that you are reading, but no one else is *writing*. It is the details of whether the container can be written to outside of the context of the read that is usually not accounted for when mistaking an item need not be latched down. For such a subtle example, [see this post](http://stackoverflow.com/questions/12579538/do-i-need-to-add-a-lock-on-a-function-that-returns-a-copy-of-a-container/12579628#12579628) – WhozCraig Nov 20 '12 at 12:51
  • This is impossible to answer just like every other "is XYZ faster or slower" question. Profile it and find out. We can give you a guess if you gave us *some* details, but right now you've given us nothing. – GManNickG Dec 06 '12 at 00:37

1 Answers1

-2

Quick answer: No.

Quite the opposite, it will speed up your program, especially if you have an object that needs to load a lot of data into memory.

Just make sure nothing can write to the object while the threads run.

Kesarion
  • 2,808
  • 5
  • 31
  • 52
  • Quick but not necessarily accurate. What if his dictionary, internally, uses chained hashes and reorders itself to keep frequently used words at the beginning of chains, or if it has a cache which is adjusted automatically? While the OP does say "Only reading operations" that may not mean what you think it means. – Nik Bougalis Dec 06 '12 at 00:19
  • 1
    It's going to unilaterally make his application faster? I can think of a number of situations where this is untrue, starvation? – Alex Dec 06 '12 at 00:19
  • This answer doesn't make sense for the same reason the question doesn't: you give no details. What does loading data into memory have to do with anything? Faster compared to what? – GManNickG Dec 06 '12 at 00:37
  • I profiled and this is the answer to my question and my code. No need to jump on my back about it, this wasn't meant as a long-winded explanation of every situation possible, this was meant as a quick and dirty way for me to save time(which I didn't because people seemed to care more about specific situations than the general outcome). This I think is what generally happens in most simple programs. Loading data into memory is one of the things my programs does and it's better(faster) to do it once rather than 2, 3 or more times. – Kesarion Dec 06 '12 at 17:44