'thread'에 해당되는 글 2건

  1. 2017.06.30 [Python] Thread example
  2. 2008.12.14 [CPP] Linux Thread Example Code
Coding/Python 삽질기2017. 6. 30. 01:51

import threading

import time



def count(s, c):

    for i in range(s, c):

        m = '+' + str(i)

        print m

        time.sleep(0.2)


def count2(s, c):

    for j in range(s, c, -1):

        n = '-' + str(j)

        print n

        time.sleep(0.1)



t1 = threading.Thread(target=count ,args=(10,100))

t2 = threading.Thread(target=count2,args=(200,101))

t1.start()

t2.start()

'Coding > Python 삽질기' 카테고리의 다른 글

[Python] Sleep  (0) 2017.07.08
Python으로 마우스 제어하기  (0) 2017.06.22
Python for Windows Extensions  (0) 2017.06.21
Posted by chobocho
Coding/CPP 삽질기2008. 12. 14. 21:49
#include <stdio.h>
#include <pthread.h>

void *Count (void *);

int main(int argc, char **argv)
{
    pthread_t p_thread[2];
    int pthread_status;

    pthread_create(&p_thread[0], NULL, Count, (void *)NULL);
    pthread_create(&p_thread[1], NULL, Count, (void *)NULL);
 
    pthread_join(p_thread[0], (void **)&pthread_status);
    pthread_join(p_thread[1], (void **)&pthread_status);

    return 0;
}


void *Count (void *arg)
{
    pthread_t thread_id = pthread_self();
    int num = 0;
   
    while (num < 10)
    {
        printf ("%x : %d\n", thread_id, num);
        num++;
        sleep(1);
    }
}


'Coding > CPP 삽질기' 카테고리의 다른 글

함수 포인터  (0) 2009.01.08
[CPP] STL에서 List의 sorting 방법  (0) 2008.10.30
Copy & Paste 신공  (0) 2008.03.08
Posted by chobocho