Does Thread give the correct answer to simplify the code?

As multiprocessor and multicore computers are becoming more and more ubiquitous, are they just causing a new stream of (relatively) simple and painless way to simplify the code? For example, in my current personal project, I have a network server listening on a port. Since this is just a personal project, it is just a desktop application with an integrated graphical interface for customization. So, the application reads something like this:

Main ()
    Read configuration
    Start listener thread
    Run GUI

Listener thread
    While the app is running
        Wait for a new connection
        Run a client thread for the new connection

Client thread
    Write synchronously
    Read synchronously
    ad inifinitum, or till they disconnect

This approach means that although I have to worry a lot about blocking, with the potential problems associated with this, I avoid a lot of spaghetti code from asynchronous calls, etc.

, . , , , , , - ( , 3-10 ). , , ... ; , , . : , .

", , "? / ?

+5
10

, , "" .

+19

.

. .

+7

, ( ) , . ", , ", . , .

+4
+4

, .

, .

+2

Amdahl, " ."

, , , .

+2

, , ? , ?

, , , ? , , , ..?

? , , ?

+1

, , , .

, ( , ) - "" , . , , "please wait".

"" ; , - , , , (, , Visual Studio). , VS , , . .

, , , , - - .NET, , - .

+1

"".

: , . .

, / ( thead) , . , , . , . " X " ", X", ( ). , . , , . , .

, :

void WorkerThreadMain(Connection connection) {
    Request request = ReadRequest(connection);
    if(!request) return;
    Reply reply = ProcessRequest(request);
    if(!connection.isOpen) return;
    SendReply(reply, connection);
    connection.close();
}

, " ", -, , / .

, , , , . , .

+1

, , , . ? . , , ?

0
source

All Articles