File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -54,16 +54,16 @@ namespace pthread {
5454 /* *
5555 * Handles POSIX (Portable Operating System Interface) threads.
5656 *
57- * <code>
57+ * <pre>< code>
5858 * class reader_thread: public runnable {
5959 * public:
6060 * void run() {...}
6161 * };
6262 *
63- * reade_thread rt;
63+ * reader_thread rt;
6464 * thread t{rt};
6565 * t.join();
66- * </code>
66+ * </code></pre>
6767 */
6868 class thread {
6969 public:
@@ -235,7 +235,22 @@ namespace pthread {
235235 *
236236 * This helper class is in charge of handling group of threads as a whole. Method in this class apply to all threads in the group.
237237 *
238- * To avoid memory lose of resources, a thread_group deletes the thread that were registered/added.
238+ * **A thread_group deletes the thread that were registered/added to it.**
239+ *
240+ <pre><code>
241+ int main(int argc, const char * argv[]) {
242+
243+ pthread::thread_group threads; // this instance will free any registered thread when it will get out of scope
244+
245+ for (auto x = 10 ; x > 0 ; x--){
246+ threads.add( new worker("herbert")); // register threads, they will run when start() is called
247+ }
248+
249+ threads.start(); // start running all threads
250+ threads.join(); // wait for registered threads to join
251+ } // scope end
252+
253+ * </code></pre>
239254 */
240255 class thread_group {
241256 public:
You can’t perform that action at this time.
0 commit comments