Typedef?struct? Msgdata{slist_entry?? nextentry;//next node int?? ID;CHAR?BUFF[20];} Stdata,*pstdata;void? Ctestthreaddlg::onbnclickedbutton17 () {pslist_entry???? Plistfirstitem,plistitem; Pslist_header??? phead;//Create head node phead?=? (pslist_header) _aligned_malloc (sizeof (Slist_header),???????????????????????????????? memory_allocation_alignment);//Initialize head node Initializeslisthead (phead);//new node data pstdata?stpdata?=? (pstdata) _aligned_malloc (sizeof (stdata),????????????????????????????????? memory_allocation_alignment); stpdata->id?=?1200;strcpy_s (stpdata->buff,?20, "message");//Add to the queue, add a node from the beginning, Return to the previous node plistfirstitem?=? Interlockedpushentryslist (phead,?&stpdata->nextentry);p listitem?=? Interlockedpopentryslist (Phead);//Remove data from the head pstdata?pdata?=? (Pstdata) Plistitem; Cstring?str (Pdata->buff); TRACE (str+_t ("\ n")); _aligned_free (Plistitem);//Release Memory Interlockedflushslist (phead);p listitem?=? Interlockedpopentryslist (Phead); (plistitem?==?) NULL) {TRACE (_t ("Empty \ n"));} _aligned_free (Phead);}
One-way linked list in multiple threads