In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Learning of three attributes of thread
Binding
Separate
Priority
Thread.c
# include "thread.h" # include#include#include#include#includeextern int status_1;extern int status_2;void thread_0 (char*pstr) / / with parameter {int counter = 10 position while (counter--) {sleep (1); printf ("% s\ n", pstr);} pthread_exit (& status_1); / / thread exit special function} void thread_1 (void) / / with no parameter {int counter = 10 position while (counter--) {sleep (1) Printf ("thread_1\ n");} pthread_exit (& status_2); / / thread exit special function} bool _ creat_thread (pthread_t * thread, void * (* start_routine) (void *), void * arg, int SCOPE, int DETACH, int policy, int priority_val) {struct sched_param param;pthread_attr_t attr If (0! = pthread_attr_init (& attr)) / / initialize the structure attr. If you do not need attr to cancel attr, pthread_attr_destroy {perror ("pthread_attr_init\ n"); return false;} if (0! = pthread_attr_setscope (& attr, SCOPE)) / / sets whether thread properties are bound (PTHREAD_SCOPE_SYSTEM) unbound (PTHREAD_SCOPE_PROCESS) {perror ("pthread_attr_setscope\ n"); return false } if (0! = pthread_attr_setdetachstate (& attr, DETACH)) / / sets whether the thread property is detached (PTHREAD_CREATE_DETACHED) non-detached (PTHREAD_CREATE_JOINABLE) {perror ("pthread_attr_setdetachstate\ n"); return false } if (0! = pthread_attr_setschedpolicy (& attr, policy)) / / three priority policy choices: SCHED_FIFO (values 1-99), SCHED_RR (values 1-99), and SCHED_OTHER {perror ("pead_attr_setschedpolicy\ n"); return false;} if (priority_val > 0 & priority_val)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.