#include <pthread.h>
#include <stdlib.h>

void *loop(void *);

int main(int argc, char *argv[]) {
	long thread_count = 2;
	pthread_t *threads = NULL;
	long i = 0;

	if (argc > 1) {
		thread_count = strtol(argv[1], NULL, 10);
	}

	threads = (pthread_t *) malloc((sizeof (pthread_t)) * thread_count);

	while (i < thread_count) {
		pthread_create(threads + i, NULL, &loop, NULL);
		i += 1;
	}

	while (i--) {
		pthread_join(threads[i], NULL);
	}

	return 0;
}

void *loop(void *_) {
	unsigned int i = 0x4fffffff;
	while (i--);
}
