Multithreading C++ loop
You're overdoing it with comments. A lot. And trivial ones at that. Every programmer knows that std::vector&lt;boost::thread *&gt; t; creates a vector of pointers to boost::thread, or that you have to use -&gt; with pointers. Such comments are really just clutter and actually make the code harder to read. Save them for the non-obvious bits.
It's unclear what mtx protects. Does it protect data? Or r? Or both? This is one of the places where you should comment, but you didn't (//Create a mutex is absolutely pointless). If possible, rename the mutex to match its purpose. It would also be a good idea to wrap the mutex and the data it protects in a class, to ensure that unsafe access is impossible.
((CORES&gt;count?count:CORES)) requires the reader to parse it (and what's with the double parentheses?) The meaning of std::min(CORES, count), on the other hand, is immediately obvious. And how does it create 4 threads? You could just as well rewrite the entire loop to make it more concise (and perhaps more efficient too):

while (count &gt; 0) {
  std::vector&lt;boost::thread *&gt; threads(std::min(CORES, count));
  for (size_t i = 0; i &lt; threads.size(); ++i) { // Start appropriate number of threads
    threads[i] = new boost::thread(threadFunction, i);
  }
  for (size_t i = 0; i &lt; threads.size(); ++i) { // Wait for all threads to finish
    threads[i]-&gt;join();
    delete threads[i];
    --count;
  }
}


Also note that I added a call to delete into the waiting loop. Your previous code was leaking the threads.
You're writing C++. Don't use (type unsafe!) C I/O. Do this instead:

{
  std::ofstream out("RandomNumbers.txt");
  for (size_t idx = 0; idx &lt; data.size(); ++idx) {
    out &lt;&lt; data[idx] &lt;&lt; '\n';
  }
}


The same holds for all other uses of C I/O (printf(), getchar()), of course.
count and CORES would be better declared with type size_t, as they represent the number of some objects.
If you have access to C++11, all the above could be simplified even further using range-based for loops, lambdas in standard algorithms, or at the very least iterator-based loops. I didn't bother with iterators here (even though they could be used), because their type has to be spelled out explicitly.

In such case, it would also make more sense not to allocate the threads dynamically, but create them directly in the vector. No need for manual deallocation, no dynamic allocation overhead.