#ifndef THREAD_H
#define THREAD_H

/*
 * @(#)Thread.h
 *
 * This file is part of webCDwriter - Network CD Writing.
 *
 * Copyright (C) 2002-2004 Jörg P. M. Haeger
 *
 * webCDwriter is free software. See CDWserver.cpp for details.
 */

#include <sys/types.h>

class Thread {
	static int activeThreads, nextID;
	static pthread_key_t key;
	static pthread_mutex_t mutex;
	static const Thread *mainThread;

	pthread_t pthread;
	int id;

public:
	Thread();
	virtual ~Thread();
	static const Thread *currentThread();
	int ID() const;
	virtual void run();
	void start();
	static void updateFirstThread(pid_t pid);

private:
	static const Thread *init();
	static void *run(void *arg);
};

#endif
