Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
EDAF55
C-camera
Commits
e68956fa
Commit
e68956fa
authored
Oct 20, 2017
by
Sven Gestegård Robertz
Browse files
thread example return values
parent
51a51fd7
Changes
1
Hide whitespace changes
Inline
Side-by-side
thread_examples/thread_example.c
View file @
e68956fa
...
...
@@ -24,7 +24,7 @@ void * task_a(void * ctx)
for
(
i
=
0
;
i
<
d
->
count
;
++
i
){
printf
(
"task_a: %d
\n
"
,
i
);
}
return
NULL
;
return
(
void
*
)
17
;
}
void
*
task_b
(
void
*
ctx
)
...
...
@@ -36,7 +36,7 @@ void * task_b(void * ctx)
for
(
i
=
0
;
i
<
d
->
count
;
++
i
){
printf
(
"task_b: %d
\n
"
,
i
);
}
return
NULL
;
return
(
void
*
)
42
;
}
...
...
@@ -45,6 +45,10 @@ int main()
struct
global_data
data
=
{
10
};
pthread_t
thread_a
;
pthread_t
thread_b
;
#ifdef RETURN_INT
void
*
ret_a
=
0
;
void
*
ret_b
=
0
;
#endif
if
(
pthread_create
(
&
thread_a
,
NULL
,
task_a
,
&
data
)){
...
...
@@ -55,7 +59,13 @@ int main()
printf
(
"Failed to create thread_b
\n
"
);
exit
(
2
);
}
#ifdef RETURN_INT
pthread_join
(
thread_a
,
&
ret_a
);
pthread_join
(
thread_b
,
&
ret_b
);
printf
(
"thread_a returned: %d
\n
thread_b returned: %d
\n
"
,
(
int
)(
long
)
ret_a
,
(
int
)(
long
)
ret_b
);
#else
pthread_join
(
thread_a
,
NULL
);
pthread_join
(
thread_b
,
NULL
);
#endif
return
0
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment