28 lines
403 B
C
28 lines
403 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "../libs/threads.h"
|
|
#include "../libs/time.h"
|
|
|
|
void* task() {
|
|
while (1) {
|
|
printf("Background task running\n");
|
|
wait(1000);
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
int main() {
|
|
void* thread_handle;
|
|
start_thread(&thread_handle, task);
|
|
|
|
printf("Main program continues\n");
|
|
wait(5000);
|
|
|
|
kill_thread(thread_handle);
|
|
|
|
printf("Background task killed\n");
|
|
|
|
return 0;
|
|
}
|