--- a/threads.c
+++ b/threads.c
@@ -5,12 +5,9 @@
#include <stdio.h>
#include <stdlib.h>
-
#include <pthread.h>
#include <time.h>
-void *thread_func (void *vptr_args);
-
void do_some_work (void)
{
time_t start_time = time (NULL);
@@ -18,6 +15,18 @@
while (time (NULL) == start_time); /* busy-wait for 0-1 seconds */
}
+void *thread_func (void *vptr_args)
+{
+ int i;
+
+ for (i = 0; i < 20; ++i) {
+ fprintf (stderr, " b\n");
+
+ do_some_work ();
+ }
+ return NULL;
+}
+
int main (int argc, char **argv)
{
int i;
@@ -33,17 +42,6 @@
pthread_join (thread, NULL);
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
-void *thread_func (void *vptr_args)
-{
- int i;
-
- for (i = 0; i < 20; ++i) {
- fprintf (stderr, " b\n");
-
- do_some_work ();
- }
- return NULL;
-}