I'd use
Code:
sed -e 's|^\([\t ]*ThreadLimit[\t ]\+\)\([-+]*[0-9]\+\)\(.*\)$|#&\n\1'"50"'|' -i file
For clarity, I separated the new parameter, 50, into a double-quoted part, so you can use e.g. a shell variable reference instead of a fixed constant.
The first subpattern will match optional whitespace, the keyword, and trailing whitespace. The second subpattern will match an integer parameter. The third subpattern will match everything trailing the parameter, if anything. The old line will be commented out, with the new one immediately following the commented out line.
If there are more than one ThreadLimit keyword (as the first token on a line, not commented out), the above will apply to each and every one.