You can use the RPC command "setgenerate true threadNumber". Bitcoin will store the number of threads to run in your wallet and remember it across runs.
How do I issue the RPC from command line?
Edit: Found it. Just set the user name and password in bitcoind.conf and run bitcoind with the given RPC command. Thanks all!