In Overload 31 Allan Kelly presented an excellent article on using Templates to endow a UDT with a multi-threading capability. What I have found most useful so far to implement multi-threading, is to reuse the Java design of its Thread and Runable classes in C++. A UDT then inherits from Thread in order to endow the sub-class with the ability to multi-thread.
I'm not saying that the template method is better or not, just that the inheritance model may work in some (different) circumstances. I for one will probably consider which model to use in future thanks to Allan.
I would strongly recommend that all C++ programmers study (or practise some) Java and import the great design ideas that Java employs. I hope that one day the C++ standard library would include the best from the Java library.
I have also considered sub-classing Runnable into a Process class for a heavy weight ('fork/exec') processes, I.e. to launch an entire new application.
Overload Journal #33 - Aug 1999 + Letters to the Editor
|Browse in :||
All > Journal Columns > LettersEditor (127)
Any of these categories - All of these categories