Skip to content

Instantly share code, notes, and snippets.

@kusa-mochi
Created June 25, 2023 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kusa-mochi/21f4a439851c69fd176254d3b926cd36 to your computer and use it in GitHub Desktop.
Save kusa-mochi/21f4a439851c69fd176254d3b926cd36 to your computer and use it in GitHub Desktop.
#include "stdio.h"
#include "pthread.h"
void *TestRoutine(void *p) {
int testVar = 123;
printf("TestRoutine - testVar:%d\n", testVar);
int *ip = (int *)p;
ip = &testVar;
}
int main(void) {
pthread_t pthread;
int *testPointer = NULL;
pthread_create(&pthread, NULL, &TestRoutine, testPointer);
pthread_join(pthread, NULL);
printf("main - testVar:%d\n", *testPointer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment