Concurrency

PostHeaderIcon Win32 Multi-Threads Programming

I’m sorry,long time has no updates.This article is also about thread,of course,multi-thread.

First,let’s see the result of this demo:

pics of one:

UI thread

pics of two:

multi-thread

multi-thread

the source code of it,also for the previous article<Create UI thread when the application startup>:

Win32MultiThreads source code(zip)

From the pic two,you can see several tests:

  1. Timer thread test;
  2. count thread(with int param) test;
  3. count thread(with struct param) test;
  4. max threads test;
  5. startup thread you saw in last article.

Read the rest of this entry »

116,967 views

PostHeaderIcon The std::thread resources

Several days ago, I introduced about the std::thread in C++,when I want to

introduce more about it, I just find there are many resources about it with

Google search!

So what we need to do is learning from the following resources:

http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=422

http://www.devx.com/SpecialReports/Article/38883/0/page/1

N1682, A Multi-threading Library for Standard C++, Pete Becker.
N1815, ISO C++ Strategic Plan for Multithreading, Lawrence Crowl.
N1883, Preliminary Threading Library Proposal for TR2, Kevlin Henney.
N1907, A Multi-threading Library for Standard C++, Revision 1 Pete Becker
N2043, Simplifying And Extending Mutex and Scoped Lock Types For C++ Multi-Threading Library, Ion Gaztañaga
N2090, A Threading API for C++, Peter Dimov
N2094, Multithreading API for C++0X – A Layered Approach, Howard Hinnant
N2139, Thoughts on a Thread Library for C++, Anthony Williams
N2178, Proposed Text for Chapter 30, Thread Support Library, Peter Dimov
N2184, Thread Launching for C++0X, Howard Hinnant
N2285, A Multi-threading Library for Standard C++, Revision 2, Pete Becker

In fact, I really do not like introduce a standard technology, because the document about

it has have many examples and demos, we need to do is to read or find something you will

use in your code.

But one you must know is the C++ thread is really coming~

116,236 views

PostHeaderIcon Hello Thread In Cplusplus

I’m sorry. I have not update this website for a long time~

Things have to do, but this is not my pretense.OK let’s begin, I will introduce something about C++ concurrency!

C++0x will come soon, so we will follow with the new standard edition for C++.

Thread is one of the new libraries in it.

First,begin with a simple hello world example:

#include <iostream>
int main()
{  
    std::cout<<"Hello World\n";
    return 0;
}

Now add the thread head file for it. and also show below(hello.cpp):

#include <iostream>
#include <thread>
void hello()
{ 
    std::cout<<"Hello Concurrent World!\n";
}
int main()
{
    std::cout<<"Hello main world!\n";
    std::cout<<"Now let's begin our first thread!\n";
    std::thread t(hello);
    t.join();
    return 0;
}

but how to build it? you hava to use g++ in linux as follow:

g++ -Wall -g -std=c++0x -pthread hello.cpp

To run it is really simple:

./a.out

The output is as follows:

Hello main world!
Now let’s begin our first thread!
Hello Concurrent World!

Simple, right? and also excited,C++ really support the thread.

Good news for C++ programmer, certainly for me!

I’ll introduce thread in recent days!

14,990 views

Copyright © 2010 - C++ Technology. All Rights Reserved.

Powered by Jerry | Free Space Provided by connove.com