{"action":"created","issue":{"url":"https://api.github.com/repos/MassTransit/MassTransit/issues/308","labels_url":"https://api.github.com/repos/MassTransit/MassTransit/issues/308/labels{/name}","comments_url":"https://api.github.com/repos/MassTransit/MassTransit/issues/308/comments","events_url":"https://api.github.com/repos/MassTransit/MassTransit/issues/308/events","html_url":"https://github.com/MassTransit/MassTransit/issues/308","id":92327848,"number":308,"title":"In-memory bus spawns hundreds of threads","user":{"login":"M0ns1gn0r","id":5908454,"avatar_url":"https://avatars.githubusercontent.com/u/5908454?v=3","gravatar_id":"","url":"https://api.github.com/users/M0ns1gn0r","html_url":"https://github.com/M0ns1gn0r","followers_url":"https://api.github.com/users/M0ns1gn0r/followers","following_url":"https://api.github.com/users/M0ns1gn0r/following{/other_user}","gists_url":"https://api.github.com/users/M0ns1gn0r/gists{/gist_id}","starred_url":"https://api.github.com/users/M0ns1gn0r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/M0ns1gn0r/subscriptions","organizations_url":"https://api.github.com/users/M0ns1gn0r/orgs","repos_url":"https://api.github.com/users/M0ns1gn0r/repos","events_url":"https://api.github.com/users/M0ns1gn0r/events{/privacy}","received_events_url":"https://api.github.com/users/M0ns1gn0r/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-01T09:29:35Z","updated_at":"2015-07-06T22:59:29Z","closed_at":null,"body":"After I configure MassTransit (3.0.10-beta) to use the in-memory bus and start it, the number of threads starts to grow. And as far as I know, without any limit (I managed to get > 300 threads).\r\n\r\nHere is the sample code:\r\n```c#\r\npublic class Program\r\n{\r\n\tpublic static void Main()\r\n\t{\r\n\t\tvar handle = Bus.Factory\r\n\t\t\t.CreateUsingInMemory(sbc => { })\r\n\t\t\t.Start();\r\n\r\n\t\tOutputThreadsNumber(20);\r\n\r\n\t\thandle.Stop();\r\n\t\tConsole.WriteLine(\"The bus is stopped.\");\r\n\r\n\t\tOutputThreadsNumber(5);\r\n\r\n\t\tConsole.WriteLine(\"Press any key to exit...\");\r\n\t\tConsole.ReadKey();\r\n\t}\r\n\r\n\tprivate static void OutputThreadsNumber(int iterations)\r\n\t{\r\n\t\tfor (int i = 0; i < iterations; i++)\r\n\t\t{\r\n\t\t\tConsole.WriteLine(\"Threads running: {0}\", Process.GetCurrentProcess().Threads.Count);\r\n\t\t\tThread.Sleep(1000);\r\n\t\t}\r\n\t}\r\n}\r\n```\r\n\r\nAnd the output:\r\n```\r\nThreads running: 17\r\nThreads running: 17\r\nThreads running: 19\r\nThreads running: 20\r\nThreads running: 21\r\nThreads running: 23\r\nThreads running: 24\r\nThreads running: 25\r\nThreads running: 26\r\nThreads running: 27\r\nThreads running: 28\r\nThreads running: 29\r\nThreads running: 30\r\nThreads running: 31\r\nThreads running: 32\r\nThreads running: 33\r\nThreads running: 34\r\nThreads running: 35\r\nThreads running: 36\r\nThreads running: 37\r\nThe bus is stopped.\r\nThreads running: 38\r\nThreads running: 38\r\nThreads running: 37\r\nThreads running: 37\r\nThreads running: 37\r\nPress any key to exit...\r\n```"},"comment":{"url":"https://api.github.com/repos/MassTransit/MassTransit/issues/comments/119022696","html_url":"https://github.com/MassTransit/MassTransit/issues/308#issuecomment-119022696","issue_url":"https://api.github.com/repos/MassTransit/MassTransit/issues/308","id":119022696,"user":{"login":"phatboyg","id":20041,"avatar_url":"https://avatars.githubusercontent.com/u/20041?v=3","gravatar_id":"","url":"https://api.github.com/users/phatboyg","html_url":"https://github.com/phatboyg","followers_url":"https://api.github.com/users/phatboyg/followers","following_url":"https://api.github.com/users/phatboyg/following{/other_user}","gists_url":"https://api.github.com/users/phatboyg/gists{/gist_id}","starred_url":"https://api.github.com/users/phatboyg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phatboyg/subscriptions","organizations_url":"https://api.github.com/users/phatboyg/orgs","repos_url":"https://api.github.com/users/phatboyg/repos","events_url":"https://api.github.com/users/phatboyg/events{/privacy}","received_events_url":"https://api.github.com/users/phatboyg/received_events","type":"User","site_admin":false},"created_at":"2015-07-06T22:59:29Z","updated_at":"2015-07-06T22:59:29Z","body":"It should stabilize once the TPL gets happy, I haven't seen hundreds personally.\r\n"}}