btncalculate_click (Object sender, eventargs e) {thread mythread = new thread (calculate); mythread. isbackground = true; // if this parameter is set to later than the program, the program is also related to the program. If this parameter is not set to true, the program is related, this program is still in the memory and will not be related to mythread. start ();} private void calculate () {stopwatch = stopwatch
second to the queue every second, and the reading thread keeps reading a value from the queue. When the read thread judges that the queue has no value, it will let out the exclusive lock and block the current thread. Then the write thread gets the exclusive lock write value and sends a notification, the first read thread in the queue is restored. Because only one thread can be notified when pulse () is used, the two read threads can read values from the queue one time in turn.
As mentioned at
1. Create Database Liezui_Test
ID int primary key auto-Increment
Title varchar (100)
ReadNum int
2. Insert 1 million data records into the databaseDeclare @ I int
Set @ I = 1
While I Begin
Insert into Liezui_Test (Title, ReadNum) values ('total execution statistics', @ I)
Set @ I = @ I + 1
End
GO
Declare @ I int
Set @ I = 1
While I Begin
Insert into Liezui_Test (Title, ReadNum) values ('towels are prone to harmful bacteria because they are often wet. ', @ I)
Set @ I = @ I + 1
End
GO
3. added
time and cause deadlocks due to mutual wait, how can this problem be solved? If you think these problems are difficult to solve, don't think about them. With Parallel. Invoke, you don't have to worry about these headaches. Let's first define three tasks:
private void Task1(){ Thread.Sleep(1000);}private void Task2(){ Thread.Sleep(2000);}private void Task3(){ Thread.Sleep(3000);}
To call these three tasks in parallel, you only need one sentence:
Parallel.Invoke(Task1, Task2, Task3);
In
No specific tests have been conducted. The 1.3 million pieces of data may be ~ About 2 seconds, but I personally feel that it is troublesome to process database paging or write conditions. It is better to use database paging!
However, this method is a way of thinking.
Private void form1_load (Object sender, eventargs E){# RegionDatatable dt = new datatable ();DT. Columns. Add ("name ");DT. Columns. Add ("name2 ");DT. Columns. Add ("type ");DT. Columns. Add ("count ");
Random ran3 = new random (
"Spring Boot 2.x start the whole process of source analysis (a) Import class analysis" We analyzed the Spring boot entry class Springapplication source code, and know its construction principle, this we continue to analyze its core run method.[TOC]Springapplication instance Run method running procedureThe above analysis of the Springapplication instance object construction method initialization process, the following continue to see the Springapplication object of the Run method of the source co
I. Establishment of a database Liezui_test
ID int PRIMARY key self-increasing
Title varchar (100)
Readnum int
two. Insert 1 million data into the databaseDECLARE @i int
Set @i=1
While @iBegin
Insert into Liezui_test (title,readnum) VALUES (' Total statistics of executions ', @i)
Set @i=@i+1
End
Go
DECLARE @i int
Set @i=1
While @iBegin
Insert into Liezui_test (title,readnum) VALUES (' towels are prone to breeding harmful bacteria because they are often damp ', @i)
Set @i=@i+1
End
Go
three. Add
There are only N people in the question. Each person has an ID and a skill value. Two contestants and a referee are required for a game, only when both the referee's ID and skill value are between two contestants can a match be held. Now, I want to know how many matches can be organized.
This is a simple tree array statistics problem. First, we need to sort the skill values from small to large, and then maintain the tree array with the ID of each co
points on the left and on the right. Therefore, two tree arrays are used to calculate the number of cattle less than the current x ln and distance and ls respectively, and the number and distance of all cattle are known,
ans += ((cc[i].x * ln - ls) + (sum - ls - cc[i].x * (i - ln)))* cc[i].v;
Then, update the number and distance tree arrays respectively.
HDU 2492 Ping Pong
Question: There are n Different Levels of table tennis players who want to perform several warm-up matches. Each warm-up
4-1 Simple output integer (10 points)
This requires implementing a function that prints all positive integers from 1 to n for a given positive integer n. function Interface Definition:
void printn (int N);
where n is the parameter passed in by the user. The function must print out all the positive integers from 1 to n, each of which takes 1 rows. Sample Referee Test procedure:
#include
Input Sample:
3
Output Sample:
1
2
3
Solution Program:
ranking.
The participants first ranked by solving the problem, the more the better. If the problem is solved by the time (penalty time) to rank, the smaller the better. If the problem is solved and the time of punishment is the same, the number of participants is from small to large row.
A participant is seen to solve a problem because the referee decides that the answer is correct (that is, accept). And the time for each participant is calculated as
an operation, or to wait until an operation completes N.A useful feature of Countdownlatch is that it does not require a thread that calls the countdown method to wait until the count arrives 0 o'clock, and before all threads can pass, it simply prevents any thread from continuing through an await.Example: Multiple athletes waiting for the referee to order: The referee and all the athletes to post the resu
amount of time. So a lot of people like to use a static object storage SqlConnection to always keep the physical connection, but when the static object, multi-threaded access will bring some problems, in fact, we do not need to do so, because the SqlConnection by default on the connection pooling function, when the program executes After Sqlconnection.close, the physical connection is not immediately released, so this occurs when the loop performs an open operation, the execution time is almost
, and the physical connection is established, these operations will not be done. These operations take a certain amount of time. So a lot of people like to use a static object storage SqlConnection to always keep the physical connection, but when the static object, multi-threaded access will bring some problems, in fact, we do not need to do so, because the SqlConnection by default on the connection pooling function, when the program executes After Sqlconnection.close, the physical connection is
Inserting a single piece of data into SQL Server uses the INSERT statement, but if you want to bulk insert a bunch of data, looping through insert is inefficient and results in a system performance problem with SQL. The following are the two bulk data insertion methods supported by SQL Server: Bulk and table-valued parameters (table-valued Parameters).Run the following script to establish the test database and table-valued parameters. Copy the code code as follows:--create database Create databa
concatenation of strings. StringBuilder is more like a mutable string type than a string-type invariance. its underlying data structure is an array of char . There is also capacity (default is 16), maximum capacity (the default is int.) MaxValue) and other properties. The advantage of StringBuilder is that when the total number of characters does not exceed the ' capacity ', the underlying array is not reassigned, which is the biggest contrast with each redistribution of the string. If the tota
) VALUES
(NEWID (), ' Cattle barn 1 ',
(newid (), ' Cattle Barn 2 segment ', 260) ...
There are four ways to implement bulk operations in C # by using ADO.Method One: Insert #region way a static void Insertone () {Console.WriteLine ("implemented in an insert-by-line manner");
Stopwatch SW = new Stopwatch ();
The using (SqlConnection conn = new SqlConnection (strconnmsg))//u
ReceiveMail() { return "Success Receive"; } }IMail
Ii. Configuration
Here, I will directly write a method for configuration and no longer define interfaces.
public DictionaryConfig
Iii. Reflection implementation
Public static object GetInstance (string InterfaceName) {// an existing object uses if (dicObj. containsKey (InterfaceName) {return dicObj [InterfaceName];} var dicConfig = new Config. config (). getAllConfig (); if (! DicConfig. containsKey (Interfac
= = Someobject.importantproperty);
Of course, this assumption may not be true in a multithreaded environment-whether using attributes or fields. However, in other cases, repeated access to the same property should be the same result.
Also, the type of consumer does not expect a property accessor to do much work. A getter that invokes a property should not affect the amount of time it takes. Similarly, the set accessor of a property may perform some validation, but it should not be too time-
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.