task queues work according to Corepoolsize and Maximumpoolsize:1. When the running thread is less than corepoolsize, line pool creates a new thread2. When the task queue is not full when it is greater than corepoolsize, the entire task is jammed into the queue3. New thread execution task is created when the task queue is larger than corepoolsize and is less than maximumpoolsize4. When greater than maximumpoolsize, threads are processed according to handler policyThere are three modes of the tas
, a new thread is created only when the queue is full. If you set the same corepoolsize and Maximumpoolsize, a fixed-size thread pool is created. If you set Maximumpoolsize to a basic unbounded value (such as Integer.max_value), the pool is allowed to accommodate any number of concurrent tasks. In most cases, the core and maximum pool sizes are only set on a construction basis, but they can also be changed dynamically using setcorepoolsize (int) and s
5 following)The data window corresponding to each row is that the range value of the previous row cannot exceed 5, and the range value of the subsequent row cannot exceed 5For exampleAa1222345679
Sum (aa) over (order by aa range between 2 preceding and 2 following)The result is:AA SUM-----------------------------------------------------------------------------1 102 142 142 143 184 185 226 187 229 9
That is to say, for a row with aa = 5, sum is the sum of 5-1 For aa = 2, sum = 1 + 2 + 2 + 2 + 3
executorsNewfixedthreadpool (Fixed-size thread pool)Create a thread pool that can reuse a set of fixed threads and run these threads in a shared, unbounded queue mode (only requests are sent and will be waiting for execution in a queue ). If any thread is terminated due to a failure during the execution before it is disabled, a new thread will execute subsequent tasks (if needed) in place of it ).
Newcachedthreadpool(The
the current line is invisible. Otherwise, false is returned. (Since 2.87)
7. Show () None this line is displayed if the current line is invisible. Note: If the current line is invisible, this function triggers the gpolyline. visibilitychanged event. (Since 2.87)
8. supportshide () Boolean if gpolyline. Hide () of the gpolyline object is supported in the current environment, true is returned. Otherwise, false is returned. (Since 2.87)
Note: If you want to display a line in the map, you need to i
(partition by deptno) by Department partition2:Over (order by salary range between 5 preceding and 5 following)The data window corresponding to each row is that the range value of the previous row cannot exceed 5, and the range value of the subsequent row cannot exceed 5For exampleAa1222345679Sum (aa) over (order by aa range between 2 preceding and 2 following)The result is:AA SUM-----------------------------------------------------------------------------1 102 142 142 143 184 185 226 187 229 9
dual-end queue.
PriorityQueue:
An unbounded priority queue based on the priority heap. The elements of the priority queue are sorted in the natural order, or by the Comparator provided when the queue is constructed, depending on the construction method used. Priority queue does not allow the use of null elements. Non-comparable objects cannot be inserted in priority queues that rely on natural order (this may cause ClassCastException ).
ArrayBlo
= 5, sum is the sum of 5-1 For aa = 2, sum = 1 + 2 + 2 + 2 + 3 + 4 = 14;For example, for aa = 9, 9-1
3: Others:Over (order by salary rows between 2 preceding and 4 following)The data window corresponding to each row is the first two rows and the last four rows4: The following three statements are equivalent:Over (order by salary rows between unbounded preceding and unbounded following)The data window corr
Getcorepoolsize ()) and maximumpoolsize (see Getmaximumpoolsize ()). When a new task is committed in method execute (java.lang.Runnable), if the running thread is less than corepoolsize, a new thread is created to process the request, even if the other worker threads are idle. If you run more threads than corepoolsize and less than maximumpoolsize, a new thread is created only when the queue is full. If you set the same corepoolsize and Maximumpoolsize, a fixed-size thread pool is created. If y
Getcorepoolsize ()) and maximumpoolsize (see Getmaximumpoolsize ()). When a new task is committed in method execute (java.lang.Runnable), if the running thread is less than corepoolsize, a new thread is created to process the request, even if the other worker threads are idle. If you run more threads than corepoolsize and less than maximumpoolsize, a new thread is created only when the queue is full. If you set the same corepoolsize and Maximumpoolsize, a fixed-size thread pool is created. If y
prefers to join the request to the queue without adding a new thread;
If the request cannot be queued, a new thread is created unless the thread is created beyond maximumpoolsize, in which case the task is rejected
There are three common strategies for queuing:1. Submit DirectlyThe default option for the work queue is synchronousqueue, which will submit tasks directly to the thread without maintaining them. Here, if there is no thread available to run the task immediately, attempting t
Executors can create
NewFixedThreadPool (int corePoolSize)
Create a thread pool with a fixed number of threads (corePoolSize = maximumPoolSize)
The core thread will always run
Unbounded queue blockingqueue
NewSingleThreadExecutor
Create a thread pool with a fixed number of threads (corePoolSize = maximumPoolSize = 1)
The core thread will always run
Unbounded queue blockingqueu
advantage is that the created thread can be reused within 60 seconds. The following is the source code of newCachedThreadPool () in Executors:
// Basic unbounded values (such as Integer. MAX_VALUE), allow the pool to adapt to any number of concurrent tasks public static ExecutorService newCachedThreadPool () {return new ThreadPoolExecutor (0, Integer. MAX_VALUE, 60L, TimeUnit. SECONDS, new SynchronousQueue
());}
(2 ).NewFixedThreadPool:The
+ 2 + 2 + 3 + 4 = 14;For example, for aa = 9, 9-1
3: Others:Over (order by salary rows between 2 preceding and 4 following)The data window corresponding to each row is the first two rows and the last four rows4: The following three statements are equivalent:Over (order by salary rows between unbounded preceding and unbounded following)The data window corresponding to each row is from the first row to the
clear from the diagram above.After about Threadpoolexecutor, let's say how to create a thread pool.newunit, workQueue, threadFactory, defaultHandler);1) corepoolsize (the basic size of the thread pool, or the size of the number of core threads): If a task is committed, the number of core threads in the thread pool is less than the base size value, or if the core thread is idle, a thread is created to perform the submitted task. It is not created when the number of threads equals the base size.N
, attempting to join the queue will fail, so a new thread is constructed. This policy avoids locking when processing a request set that may have internal dependencies. Direct submissions typically require unbounded maximumpoolsizes to avoid rejecting newly submitted tasks. This policy allows for the possibility of growth without a line when the command arrives continuously in excess of the averages that the queue can handle.
also apply this strategy to the core thread, which we can implement by invoking Allowcorethreadtimeout.
correct selection of queues
The following are mainly the performance of different queue strategies:
Direct submission: A better default option is to use Synchronousqueue, which sends the submitted task directly to the worker thread without holding it. If there are currently no worker threads to process, that is, the task is queued for failure, a new worker thread creation is raised based o
first, review the previous Oracle Development window function in the section on the full statistics, we use Oracle-provided:
Copy Code code as follows:
SUM (SUM (tot_sales)) over (order by month rows between unbounded preceding and unbounded)
To count the total amount of orders for the whole year, this function is executed once for each record in the Recordset formation, and it executes
a style, and the style is represented by a character with ' 9 '; 5:round is the value of the number, rounded; The 6:over function specifies the size of the data window in which the parsing function works, and the size of the data window may change as the row changes, for example:Over (order by salary) is cumulative by salary sort, and order by is a default window-opening functionOver (partition by Deptno) according to departmental zoningOver (order by salary range between preceding and followin
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.