Parallel thread usage, parallel thread
Public void run (Action <List <string> onload)
{
List <string> directoryLists = new List <string> ();
DirectoryLists = Directory. GetDirectories (m_importPath). ToList ();
Parallel. ForEach (directoryLists, new ParallelOptions {MaxDegreeOfParallelism = 10}, I =>
{
List <string> files = importer (I );
Onload (files );
}
}
Action <List <string> onload = dir =>
{
BeginInvoke (new EventHandler (obj, even) =>
{
Var root = new TreeNode (dir [0]);
For (int I = 1; I <dir. Count; I ++)
{
String fileName = dir [I]. Substring (dir [I]. LastIndexOf ('\') + 1 );
Root. Nodes. Add (fileName. Remove (fileName. IndexOf ('.')));
}
This. treeView1.Nodes. Add (root );
}), Null );
};
Import. run (onload );
Net Parallel Why are currently few projects used?
Because most of the time we write code, we focus on processing transactions rather than efficiency.
Considering that most objects in. net are not thread-safe, parallel has great limitations in use.
It can only play a role in intensive computing.
The efficiency of parallel + LINQ is almost the same as the efficiency of the original Circular code.
I will still consider using parallel when it comes to scenarios that require efficiency, for example, a 100,000-level loop ..
In addition, many times we are unknowingly using parallel features... The async and await of 4.5 are also considered one aspect.
What's more, asp.net's own execution mode is multithreading...
What is Oracle Parallel Mode?
Oracle Parallel usage Oracle technology 15:51:08 read 105 comments 0 font size: large and small subscriptions.
1. Parallel
1. Purpose
Enable the degree of parallelism to execute the current SQL statement. This version can be used in Versions later than Oracle 9i. Earlier versions do not have an environment for testing. That is to say, you can forcibly enable the multi-thread processing function of Oracle. For example, if a computer is equipped with a multi-core CPU, but in most cases it will not be fully enabled at the same time (more obvious than 2 cores), use parallel to describe, it will work in multiple cores at the same time to improve efficiency.
However, starting this function also consumes resources and performance. Generally, this function is used when the number of returned records is greater than 1 million, and the effect is obvious.
2. Syntax
/* + Parallel (table_short_name, cash_number )*/
This can be used after insert, delete, update, and select (similar to rule usage, and the chance to share rule usage)
The statement for enabling parallel is:
Alter session enable parallel dml;
This statement is a DML statement. If it is used in a program, use the execute method to open it.
3. instance description
Use the transaction in ERP to describe it. This table records all the transactions, and the daily data volume is relatively large (depending on the business volume of the enterprise ). Assume that we want to check the monthly sales and promotion information of the past year. Therefore, we generally write the following statements:
Select to_char (transaction_date, 'yyyymmm ') txn_month,
Sum (
Decode (
Sign (transaction_quantity), 1, transaction_quantity, 0
)
) In_qty,
Sum (
Decode (
Sign (transaction_quantity),-1, transaction_quantity, 0
)
) Out_qty
From mtl_material_transactions Mt
Where transaction_date> = add_months (
To_date (
To_char (sysdate, 'yyyy') | '2013', 'yyyymmdd '),
-12)
And transaction_date <= add_months (
To_date (
To_char (sysdate, 'yyyy') | '2013', 'yyyymmdd '),
-12)
Group by to_char (transaction_date ...... remaining full text>