V3082. The 'Thread' object is created but is not started. It is possible that a call to 'Start' method is missing.

The analyzer detected a suspicious code fragment where an object of type 'Thread' is created but the new thread is not started.

Consider the following example:

void Foo(ThreadStart action)
{
  Thread thread = new Thread(action); 
  thread.Name = "My Thread";
}

In this code, an object of type 'Thread' is created, and the reference to it is written into the 'thread' variable. However, the thread itself is not started or passed anywhere. Therefore, the created object, which will not have been used in any way, will simply be erased the next time garbage collection occurs.

To fix this error, we need to call the object's 'Start' method, which will start the thread. The fixed code should look something like this:

void Foo(ThreadStart action)
{
  Thread thread = new Thread(action); 
  thread.Name = "My Thread";
  thread.Start();
}

According to Common Weakness Enumeration, potential errors found by using this diagnostic are classified as CWE-563.


Bugs Found

Checked Projects
410
Collected Errors
14 111
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site. Learn More →
Accept