Ticket #4665: threadtest.cpp

File threadtest.cpp, 582 bytes (added by anevilyak, 15 years ago)

Testcase that reproduces the problem

Line 
1#include <stdio.h>
2#include <string.h>
3#include <OS.h>
4
5status_t threadfunc(void *data)
6{
7 printf("Thread test: %s\n", (const char *)data);
8
9 snooze(5 * 1000000L);
10
11 return 0;
12}
13
14
15int main(int, char **)
16{
17 printf("Starting test thread\n");
18
19 thread_id testThread = spawn_thread(threadfunc, "test thread", B_NORMAL_PRIORITY, (void *)"This is a test");
20
21 if (testThread >= B_OK) {
22 status_t result;
23 wait_for_thread(testThread, &result);
24 printf("Test thread exited: %ld\n", result);
25 } else {
26 printf("Failed to spawn test thread: %s\n", strerror(testThread));
27 }
28
29 return 0;
30}
31