The class Thread
is a sealed class meaning it cannot be inherited from and I need an instance of a reusable Thread
that should inherit from the Thread class. Does anyone have an idea how i can reuse tread ?
A preferable alternative to using Inheritance is to use Composition. Create your class and have a member of type Thread
. Then map the methods of your class to call methods from the Thread member and add any other methods you may wish. Example:
public class MyThread
{
private Thread thread;
// constructors
public void Join()
{
thread.Join();
}
// whatever else...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With