Free preview.You're sampling one lesson — enroll free to unlock all 8 lessons and track your progress.
Enroll free lesson
Concurrency vs. Parallelism
Concurrency vs. Parallelism
In this lesson — part of Concurrency Basics — you'll learn concurrency vs. parallelism in C and why it matters in real work.
Why it matters
Modern programs wait on networks and disks — async lets them stay responsive.
Key ideas
- Blocking vs. non-blocking
- Callbacks, promises, async/await
- Concurrency vs. parallelism
- Error handling in async code
In practice
Here's how it looks in idiomatic C:
#include <stdio.h>
#include <pthread.h>
/* C has no async/await; the idiomatic model is threads. A "future"
is a thread whose result you collect with pthread_join. */
static int result;
void *compute(void *arg) { result = *(int *)arg * 2; return &result; }
int main(void) {
pthread_t t; int in = 21; void *out;
pthread_create(&t, NULL, compute, &in);
pthread_join(t, &out); /* "await" */
printf("%d\n", *(int *)out);
return 0;
}
C note: C has no async/await or event loop in the language; concurrency is done with OS threads (POSIX pthreads), where pthread_join is the closest thing to awaiting a result.
Try it yourself
Exercise: In C, fetch two things concurrently and combine the results.
Recap
You now understand concurrency vs. parallelism and can apply it in C. Mark this lesson complete and continue to the next one.
