Alternative to threads

I read that threads are very problematic. What alternatives are available? Something that automatically handles locks and stuff?

Many recommend a background worker, but I have no idea why.

Anyone want to explain the "simple" alternatives? The user will be able to choose the number of threads used (depending on their needs for speed and computer power).

Any ideas?

+5
source share
9 answers

To summarize threading issues:

  • If threads exchange memory, you can get race conditions
  • , , (. )

: , , . 1 CPU. 2 . 1 . 2 . : 1, . . , , .

, : . . TCP/IP .

, , .

+6

, , . , ( ) , , .NET 4.0, , . Erlang ( , Ericsson). (, F #), , . genral:

  • ( ) , . , ( ).

  • ( TPL .NET 4.0) - , runtime ( ). , , - .

  • (PLINQ .NET 4.0 - ), , LINQ, , , LINQ , ( , ).

  • , ( ) , . , ( ) ( , ). F # .

, - , - - , ( ). ( ).

, F # . # Concurrency Coordination Runtime, "", , , ( ).

+5

.Net 4 "" ? , .Net 3.5 ...

MSDN Parellel, ..

+2

. Smart Thread Pool

Smart Thread Pool - , #. , .NET. :

  • .
  • .
  • .
  • , ().
  • Win32, .
  • .
  • PostExecute, , .
  • , , .
  • .
  • .
  • .
  • .
  • .
  • COM-, .
  • Func.
  • WindowsCE ()
  • MaxThreads MinThreads .
  • .
+1

"" - , . "Tedious" - .

, . , . - , , .

#, , .

  • BackgroundWorker, , . . BackgroundWorker, (1) System.Windows.Form, (2) , , (3) .
  • ThreadPool, . ThreadPool , , . ThreadPool, (1) , (2) , , (3) (4) (, , ).
  • Thread , , , , , ..
+1

, , , . , , , , , .

..NET , , BackgroundWorker, .

.NET 4 , . PLINQ .

:

( ).

.NET ThreadPool. .NET 4 TPL , , . .

ThreadPool.SetMaxThreads, . TPL ParallelOptions.MaxDegreesOfParallelism ParallelOptions , . , , .

+1

, , .

, , , API (, ), , .

0

( , / dll, . , .. . Windows. , , .

0

Topics are indispensable tools for solving many problems, and ripening developers need to know how to use them effectively. But, like many tools, they can cause some very difficult to find errors.

Do not shy away from some so useful just because it can cause problems, not learn and practice until you become a member of multi-threaded applications.

A great place to start is Joe Albahari's article: http://www.albahari.com/threading/ .

0
source

All Articles