MySQL: Find ID with only 2 attached IDs in subtable
You've tagged your question with "t-sql", so here goes (although I think/hope that this should be ANSI SQL compliant) :

SELECT DISTINCT mt.ThreadID
FROM MessageThreads AS mt
INNER JOIN MessageThreadAccessUsers AS mtau1 ON mtau1.ThreadID=mt.ThreadID AND mtau1.UserID=1
INNER JOIN MessageThreadAccessUsers AS mtau2 ON mtau2.ThreadID=mt.ThreadID AND mtau2.UserID=2
LEFT JOIN  MessageThreadAccessUsers AS mtau3 ON mtau3.ThreadID=mt.ThreadID AND mtau3.UserID NOT IN (1, 2)
WHERE mtau3.ThreadID IS NULL;


This is probably more efficient than a GROUP BY with conditional SUM()s, particularly so if you have an index on MessageThreadAccessUsers that covers the columns (ThreadID, UserID). If users are distinct for each thread, you can even remove DISTINCT.

Edit: Added LEFT JOIN and WHERE .. IS NULL to exclude any other users.