#ifndef VLIB_THREAD
#define VLIB_THREAD
#ifndef WIN32
#ifdef DOTHREADS
#include <pthread.h>
#endif
#else
#include <windows.h>
#endif

#ifdef WIN32
typedef struct THREAD {
	HANDLE h;
} Thread;
typedef struct MUTEX {
	HANDLE h;
} Mutex;
#else
typedef struct THREAD {
#ifdef DOTHREADS
	pthread_t h;
#else
	int h;
#endif
} Thread;
typedef struct MUTEX {
#ifdef DOTHREADS
	pthread_mutex_t h;
#else
	int h;
#endif
	int nref;
	int threadid;
} Mutex;
#endif
Thread *th_new(int fn(void *x),void *arg);
int th_free(Thread **tt);
Mutex *th_mutex_new(char *name) ;
int  th_mutex_wait(Mutex *m, unsigned int timeout);
int  th_mutex_release(Mutex *m);
int th_pid(void);
int th_id(void);
void th_mutex_free(Mutex *m);
int th_exit(int x);

#endif
