1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * thread.c
 *
 *  Created on: 21.02.2013
 *      Author: dgok50
 */


#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <ctype.h>
#include <func.c>

static int x=0;

char* te;
char** ts;
int f=0;

void* aang112_thread(void *arg)
{

    while ( x==0 )
    {
        printf("I'm New Thread1!\n");
        sleep(1);
    }

    printf("Thread EXIT\n");
    return NULL;
    free(te);<--- Statements following return, break, continue, goto or throw will never be executed.
}

void* test_thread(void *arg)
{
    int i;
    while ( x==0 )
    {
        printf("I'm New Thread2!\nTe:%s\n",te);
        sleep(3);
    }

    printf("Thread EXIT\n");
    return NULL;
    for(i=0; f < i; i++) free(ts[u]);<--- Statements following return, break, continue, goto or throw will never be executed.
}

int main()
{
    pthread_attr_t attr;
    pthread_t info;
    pthread_attr_init(&attr);
    int t=0;
    printf("Enter leg:");
    scanf("%d",&t);
    te = (char *)malloc(t*sizeof(char));
    ts = (char **)malloc(t*sizeof(char))

         printf("Enter word:");
    scanf("%s",te);<--- scanf() without field width limits can crash with huge input data.

    ts=(char *)malloc(t*sizeof(char));
    printf("Enter word:");
    scanf("%s",te);<--- scanf() without field width limits can crash with huge input data.

    if (pthread_create(&info, NULL, aang112_thread, NULL) != 0)
    {
        printf("Unable to start thread\n");
    }

    if (pthread_create(&info, NULL, test_thread, NULL) != 0)
    {
        printf("Unable to start thread\n");
    }


    sleep(10);

    x=1;

    sleep(3);

    printf("MAIN EXIT\n");
    return 0;
}