athread.c

来自「adios在windows的实现」· C语言 代码 · 共 51 行

C
51
字号
/***************************
 * AdiOS Threading Example *
 * athread.c               *
 * 16-10-2001              *
 ***************************/

// Entry point and kernel API defined here
#include "..\kernapi.h"

// The second thread prototype
void * OtherThread(__int32 param);

// A semaphore
unsigned int Semaphore;

void * appmain(__int32 param)
{
	// Let the world know we're coming
	PrintCR("App Started, launching second thread.");

	// Create out output semaphore
	Semaphore = CreateSem(1);

	// Launch the second thread
	StartThread(&OtherThread, 0);

	// Enter an infinite loop
	while(1){
		WaitSem(Semaphore);
		Print("A");
		ReleaseSem(Semaphore);
	}

	return 0; // Keep the compiler happy
}

// This is the second thread
void * OtherThread(__int32 param)
{
	// To help with debugging.
	PrintCR("Second Thread Started...");

	// Enter an infinite loop
	while(1){
		WaitSem(Semaphore);
		Print("B");
		ReleaseSem(Semaphore);
	}

	return 0; // Keep the compiler happy
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?