// ------------------------------- // // -------- Start of File -------- // // ------------------------------- // // ----------------------------------------------------------- // // C++ Source Code File Name: testprog.cpp // Compiler Used: MSVC40, egcs-2.90.29, HP CPP 10.24 // Produced By: Doug Gaer // File Creation Date: 03/25/2000 // Date Last Modified: 05/17/2000 // Copyright (c) 2000 Douglas M. Gaer // ----------------------------------------------------------- // // ------------- Program Description and Details ------------- // // ----------------------------------------------------------- // /* The VBD and VBS C++ classes are copyright (c) 1997 and 2000 by Douglas M. Gaer. All those who put this code or its derivatives in a commercial product MUST mention this copyright in their documentation for users of the products in which this code or its derivative classes are used. Otherwise, you have the freedom to redistribute verbatim copies of this source code, adapt it to your specific needs, or improve the code and release your improvements to the public provided that the modified files carry prominent notices stating that you changed the files and the date of any change. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK OF THE QUALITY AND PERFORMANCE OF THIS SOFTWARE IS WITH YOU. SHOULD ANY ELEMENT OF THIS SOFTWARE PROVE DEFECTIVE, YOU WILL ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. Simple test program demonstrating the basic operation of the vbThread class using templates. */ // ----------------------------------------------------------- // #include <iostream.h> #include "vbthread.h" template <class TYPE> class SimpleThread : public vbThread { private: // Base class interface void *ThreadEntryRoutine(vbThread_t *thread); }; template <class TYPE> void *SimpleThread<TYPE>::ThreadEntryRoutine(vbThread_t *thread) // Thread's entry function { cout << endl; TYPE info = *((TYPE *)thread->GetThreadParm()); cout << "Executing thread: " << info << endl; return 0; } // Program's main thread of execution int main() { SimpleThread<int> t1; SimpleThread<char> t2; SimpleThread<char *> t3; int i = 5; t1.CreateThread((void *)&i); // Create and execute a thread t1.sSleep(1); // Wait for the thread to exit char c = 'A'; t2.CreateThread((void *)&c); t2.sSleep(1); char *s = "TEST"; t3.CreateThread((void *)&s); t3.sSleep(1); return 0; // Exit the process, terminating all threads } // ----------------------------------------------------------- // // ------------------------------- // // --------- End of File --------- // // ------------------------------- //