Privacy Policy

Privacy Policy   ============== Last updated: June 08, 2024 This Privacy Policy describes Our policies and procedures on the collection, use and disclosure of Your information when You use the Service and tells You about Your privacy rights and how the law protects You. We use Your Personal data to provide and improve the Service. By using the Service, You agree to the collection and use of information in accordance with this Privacy Policy. This Privacy Policy has been created with the help of the [Privacy Policy Generator](https://www.termsfeed.com/privacy-policy- generator/). Interpretation and Definitions   ------------------------------ Interpretation   ~~~~~~~~~~~~~~ The words of which the initial letter is capitalized have meanings defined under the following conditions. The following definitions shall have the same meaning regardless of whether they appear in singular or in plural. Definitions   ~~~~~~~~~~~ For the purposes of this Privacy Policy:   * Account means a unique acc

Membuat Thread Sederhana (Bagian 1)

1. Siapkan komputer atau laptop dengan sistem operasi Linux dan compiler gcc
2. Buka text editor
3. Ketikkan kode berikut :
a. ) simple thread

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

void *print_message_function1(void *ptr);
void *print_message_function2(void *ptr);

int max1=15;
int max2=10;
int main()
{
    pthread_t thread1, thread2;
   
    pthread_create( &thread1, NULL, &print_message_function1, NULL );
    pthread_create( &thread2, NULL, &print_message_function2, NULL );
    puts("press enter");
    getchar();
}

void *print_message_function1(void *ptr)
{
    int i = 0;
    char *message="Pesan dari thread 1";
    for(i=0;i<max1;i++) printf("%s \n", message);

    return NULL;
}

void *print_message_function2(void *ptr)
{
    int i = 0;
    char *message="Pesan dari thread 2";
    for(i=0;i<max2;i++) printf("%s \n", message);

    return NULL;
}


4. Simpan dengan nama thread.c
5. Compile dengan gcc thread thread.c -lpthread
6. Coba jalankan berulang-ulang dan amati hasil outputnya

Komentar

Postingan populer dari blog ini

State Diagram & Analisa Rangkaian Sekuensial (Rangkaian Sekuensial 2)

Adder, Subtractor, Decoder, Encoder

Penyederhanaan Fungsi Boolean (Tabulasi), Rangkaian Kombinasional