editor << letters;

editor << letters;

By Aaron Ridout

Overload, 7(33):, August 1999

Java Threads

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.

Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED

By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED

Settings can be changed at any time from the Cookie Policy page.