47 lines
1006 B
Plaintext
47 lines
1006 B
Plaintext
#ifdef __FB_WIN32__
|
|
' ... instructions only for Win ...
|
|
#Include "windows.bi"
|
|
|
|
Function ThreadFunc As Dword Cdecl Alias "ThreadFunc"(param As Any Ptr) Export
|
|
Print "Thread running"
|
|
Function = 0
|
|
End Function
|
|
|
|
Dim As HANDLE thread
|
|
Dim As Dword threadId
|
|
|
|
thread = CreateThread(NULL, 0, @ThreadFunc, NULL, 0, @threadId)
|
|
|
|
If thread = NULL Then
|
|
Print "Error creating thread"
|
|
Sleep
|
|
End 1
|
|
End If
|
|
|
|
WaitForSingleObject(thread, INFINITE)
|
|
#endif
|
|
|
|
#ifdef __FB_LINUX__
|
|
' ... instructions only for Linux ...
|
|
#Include "crt/pthread.bi"
|
|
|
|
Function ThreadFunc As Any Ptr Cdecl Alias "ThreadFunc"(param As Any Ptr) Export
|
|
Print "Thread running"
|
|
Function = 0
|
|
End Function
|
|
|
|
Dim As pthread_t thread
|
|
|
|
If pthread_create(@thread, NULL, @ThreadFunc, NULL) <> 0 Then
|
|
Print "Error creating thread"
|
|
Sleep
|
|
End 1
|
|
End If
|
|
|
|
pthread_join(thread, NULL)
|
|
#endif
|
|
|
|
Print "Thread finished"
|
|
|
|
Sleep
|