小编pri*_*ess的帖子

Python 3中的整数除法 - 带有负数的奇怪结果

我是Python新手,我现在正在学习操作员.我明白:

  • /运营商用于floating point division
  • //integer division.

例:

7//3 = 2
Run Code Online (Sandbox Code Playgroud)

并且7//-3=-3.为什么答案-3

我被困在这里.

python integer-division python-3.4

16
推荐指数
2
解决办法
2353
查看次数

使用pthread_create创建的线程的输出未打印

我正在学习Tanenbaum的Modern Operating systems中的线程和POSIX线程.这是我正在尝试的一个例子:

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

void *print_hello(void *tid)
{
    printf("Hello..Greetings from thread %d\n",tid);
    pthread_exit(NULL);
}

int main()
{
    pthread_t threads[10];
    int status,i=0;

//  for(i=0;i<10;i++){
        printf("Creating thread %d\n",i);
        status = pthread_create(&threads[i],NULL,print_hello,(void*)i);

        if(status != 0){
            printf("Oops pthread_create returned error code %d\n",status);
            exit(-1);
        }
//  }
    exit(0);
Run Code Online (Sandbox Code Playgroud)

}

输出是:

Creating thread 0
Run Code Online (Sandbox Code Playgroud)

为什么不去我的start_routine,这是什么print_hello功能?这有什么不对?

提前致谢.

c linux multithreading pthreads

2
推荐指数
1
解决办法
364
查看次数