J
Jon Skeet [C# MVP]
Kiran said:Jon Skeet,
Its some good work u have in there. you have almost covered all the
technical aspect that goes in with handling the thread. I have already give
a print!!.
Having said this, I'll like to add that, I generally like to treat a Thread
as an fully self managed Object rather than a method of an object that is
used by thread(so to say...). OK now I am confusing... what I mean is(more
of a design issue), in every example I see, there are code written like
this:
ThreadStart job = new ThreadStart(myobj.ThreadJob);
Thread thread = new Thread(job);
thread.Start();
well there is nothing wrong with this, but I like to see something like
MyThread thread = new MyThread();
this makes my design lot cleaner to understand, How I do this is something
like this.
this way the method that is run in the thread & the thread itself are
treated as from single object.
Whereas I would discourage that approach. It's the one that Java took
until it gained the Runnable interface, and these days most people will
strongly discourage people from subclassing Thread in Java.
I see no advantage in conflating the two ideas, to be honest. There's
nothing wrong with having a general purpose class which can be used to
start a thread and is still provided with a ThreadStart delegate to
actually run, but to restrict things by derivation is a bad idea, in my
view.