main_work.c

来自「书店管理系统」· C语言 代码 · 共 58 行

C
58
字号
#include"nesoft.h"
#include"press.c"
#include"bookstore.c"
#include"bookbuyer.c"

main ()
{
  
  char a_id='A';
  char b_id='B';
  char c_id='C';
  char d_id='D';
  char e_id='E';
  char f_id='F';
  char g_id='G';

  //C D E书店初始化 
  store_beginer();

  //注册F和G购买者到E书店
  e_licence();
     
  //A B 出版社初始化
  press_begin();

  //A B 出版社注册书店C D E 
  license(c_id );
  license(d_id);
  license(e_id);


  //creat threads to run!!!!
  pthread_t a_press;
  pthread_t b_press;        
  pthread_create(&a_press, NULL,(void *)press_new, (void *)&a_id);
  pthread_create(&b_press, NULL,(void *)press_new, (void *)&b_id);
   
  pthread_t c_store;
  pthread_t d_store;
  pthread_create(&c_store, NULL,(void *)sell_book, (void *)&c_id);
  pthread_create(&d_store, NULL,(void *)sell_book, (void *)&d_id);
  
  pthread_t f_buyer;
  pthread_t g_buyer;
  pthread_create(&f_buyer, NULL,(void *)buy_from_e_store, (void *)&f_id);
  pthread_create(&g_buyer, NULL,(void *)buy_from_e_store, (void *)&g_id);
 
  //等待线程结束!!!
  pthread_join(a_press,NULL);
  pthread_join(b_press,NULL);
  pthread_join(c_store,NULL);
  pthread_join(d_store,NULL);
  pthread_join(f_buyer,NULL);
  pthread_join(g_buyer,NULL);
  
 
}//end main

⌨️ 快捷键说明

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