Compare commits
2 Commits
3a07a9b5ed
...
6bbd07c028
| Author | SHA1 | Date | |
|---|---|---|---|
| 6bbd07c028 | |||
| ccd43f25c7 |
+3
-2
@@ -2,11 +2,12 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "../libs/threads.h"
|
#include "../libs/threads.h"
|
||||||
|
#include "../libs/time.h"
|
||||||
|
|
||||||
void* task() {
|
void* task() {
|
||||||
while (1) {
|
while (1) {
|
||||||
printf("Background task running\n");
|
printf("Background task running\n");
|
||||||
wait(1);
|
wait(1000);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -16,7 +17,7 @@ int main() {
|
|||||||
start_thread(&thread_handle, task);
|
start_thread(&thread_handle, task);
|
||||||
|
|
||||||
printf("Main program continues\n");
|
printf("Main program continues\n");
|
||||||
wait(5);
|
wait(5000);
|
||||||
|
|
||||||
kill_thread(thread_handle);
|
kill_thread(thread_handle);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
printf("Wait 5 seconds...\n");
|
printf("Wait 5 seconds...\n");
|
||||||
wait(5);
|
wait(5000);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "time.h"
|
|
||||||
|
|
||||||
void start_thread(void** thread_handle, void* (*task)(void*)) {
|
void start_thread(void** thread_handle, void* (*task)(void*)) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|||||||
+2
-2
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
void wait(int time) {
|
void wait(int time) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
Sleep(time*1000);
|
Sleep(time);
|
||||||
#else
|
#else
|
||||||
sleep(time);
|
usleep(time * 1000);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user