Fixed size thread pool with the exception of the additional tasks, then it must

Hello
I have the following code in a simple program (code below)

BlockingQueue < Runnable > q = new < Runnable > ArrayBlockingQueue (10, false);
NewPool ThreadPoolExecutor = new ThreadPoolExecutor (1, 10, 20, TimeUnit.SECONDS, q);

for (int x = 0; x < 30; x ++) {}
newPool.execute (new threaded());
}


My understanding is that this should create a pool of threads that can accept 10 tasks, once there were 10 submitted tasks I should get RejectedExecutionException, however; I see that when I run the code the pool accepts 20 run calls before launching RejectedExecutionException. I am on Windows 7 using Java 1.6.0_21

Any thoughts on what I am doing wrong?

Thank you

-----


java.util.concurrent import. *;

public class ThreadPoolTest {}
Public NotInheritable class threaded implements Runnable {}

@Override
public void run() {}
System.out.println ("wire:" + Thread.currentThread () .getId ());
try {}
Thread.Sleep (5000);
} catch (InterruptedException e) {}
System.out.println ("Thread:" + Thread.currentThread () .getId ())
"+"interuptted");
}
System.out.println ("output wire:" + Thread.currentThread () .getId ());
}

}

private static int MAX = 10;
private pool of the executor;


public ThreadPoolTest() {}
Super();
BlockingQueue < Runnable > q is new ArrayBlockingQueue < Runnable > (MAX/2, false);.
NewPool ThreadPoolExecutor = new ThreadPoolExecutor (1, MAX, 20, TimeUnit.SECONDS, q);

pool = newPool;
}



/**
@param args
*/
Public Shared Sub main (String [] args) {}
Object ThreadPoolTest = new ThreadPoolTest();
object.doThreads ();
}

private void doThreads() {}
int argued = 0, rejected = 0;
for (int x = 0; x < MAX * 3; x ++) {}
try {}
System.out.println (Integer.ToString (x) + "sending");
pool. Execute (new threaded());
submitted ++;
}
{} catch (RejectedExecutionException re)
System.Err.println ("Submission" + x + "rejected");
rejected ++;
}
}

System.out.println ("\n\nSubmitted:" + MAX * 2);
System.out.println ("Accepted:" + subject);
System.out.println ("rejected:" + rejected);
}

}

Interesting, it seems to not dismiss after (size of queue + size of thread pool) supports.

--
In fact, it's not interesting. The queue is the buffer and the thread pool size is job tasks.
He uses the thread pool, the rest first upward, puts it on the queue for a free thread. If both are filled, so there is no space and it rejects submit it.

Published by: Kayaman April 4, 2011 20:39

Tags: Java

Similar Questions

  • No problem with the addition of a Kingston SSDNow V300 240 GB SDD to a D7-1245dx?

    A knowledge of any problems with the addition of a Kingston SSDNow V300 240 GB SDD to a D7-1245dx? Its size is 7mm width 69,85 mm x depth 100mm height but not sure of the size of the computer laptop berries/caddy supports

    Decide whether to use the laptop for a little longer so to upgrade the system to a Kingston 240 GB SDD drive and move the current drive to the secondary location (already got 2nd coming of caddy). It lets me do a bit more space on the laptop in addition to increasing performance.  Figure between an SSD and get up to 8 GB ram it should last a little longer.

    You will have a shopping cart for the SSD, but it looks like you have an and get a second wagon. Dv7-1000 series does not use a cable or connector. the hard disk plug right into SATA ports on the motherboard. 7mm drive has the connectors SATA and the mounting holes exactly in the same place as a 9.5 mm drive. All is just shorter so the reader rides low in the caddy. As a swimming pool with 20% water let out. 7mm SSD works perfectly. Windows 7 or 8/8.1 are preferred; Vista is not configured to treat SSDS as well or easily.

    If it's 'the Answer' please click on 'Accept as Solution' to help others find it.

  • Hi, I had problems with the addition of soundtrack to Adobe premiere elements 13. When I add it or drag it immediately comes crashing windows, where says "Adobe Premiere Elements has stopped working". I can add videos with no problems, but cannot add any

    Hi, I had problems with the addition of soundtrack to Adobe premiere elements 13. When I add or drag it happens immediately windows crash, where says "Adobe Premiere Elements has stopped working". I can add videos with no problems, but cannot add .mp3 files.

    I had Windows 8.1, 2.4 GHz, 6 GB of RAM. How to solve this problem?

    Fixed a problem when converting the mp3 file. WAV...

    some poor Adobe Premiere Elements if there is for example simple bug in the software.  Waste of money for this software.

  • can someone help me with the addition of an account for child microsoft under a perintal account

    need of assistants with you that links child account to perintal for the child account is connected to Xbox live Microsoft account. He is asked to accept the terms of use on the Xbox site. She also asked inter in perinatal password and ID. The perinatal e-mail password was disassociated from the perinatal account. went to account.live.com account add kid account with parental account but how always to choose the option to add an account it takes me to a new page and I don, t know how to navigate the page. Can someone from Microsoft help me please with the addition of my son's account to my account.

    Hello

    Did you manage on behalf of your son using a parent account? You have already set up a parental control using the Windows parental control? If it isn't yet, please visit the link below on how to set up parental controls on your son's account by using Windows parental control:

    Bind the child account for a Parent account

    You can also download the installer of Windows parental control in the link below:

    http://Windows.Microsoft.com/en-us/Windows-Live/Essentials-home

    If you have any other questions, please let us know.

    Thank you!

  • Error: A connection has been established with the server, but then an error occurred during the connection process.

    Hello

    I have MsSql running in the cluster environment and recently face the problem when there is a security agent installed in MsSql server, which the agent does nothing but only to capture the local database activity. The error led is as below:

    ID from step 1

    Server NIBKSQLCLUST

    Job name LSBackup_DRIB

    Newspaper log shipping backup job step name.

    Time 00:00:02

    SQL severity 0

    SQL Message ID 0

    Operator by e-mail

    Operator Net sent

    Operator paged

    Retries attempted 0

    Message

    2011-03-21 08:00:02.62 * error: could not retrieve parameters of backup for primary ID '26f46141-a676-41b2-8653-11f1b13de43a '. (Microsoft.SqlServer.Management.LogShipping) *.

    2011-03-21 08:00:02.63 * error: could not connect to the server NIBKSQLCLUST. (Microsoft.SqlServer.ConnectionInfo) *.

    2011-03-21 08:00:02.63 * error: a connection has been established with the server, but then an error occurred during the connection process. (provider: Named Pipes Provider, error: 0 - no process is on the other end of the pipe.) (.Net SqlClient data provider) *.

    2011-03-21 08:00:02.63 - END OF THE TRANSACTION LOG BACKUP-

    The process to run correctly when I turned off the security officer. Advice kindly the cause of this problem and is where all configurations should be set / changed in MsSql server.

    Thank you

    Boonlep coulibaly

    Hello

    I suggest you to send your request from the link and check.

    http://msdn.Microsoft.com/en-us/hh361695.aspx

    http://msdn.Microsoft.com/en-us/library/bb545450.aspx

  • Can I run a service at regular intervals with the Windows Task Scheduler?

    Hai...

    I want to run a service on a regular basis. I was thinking about tasks windows schedular system. I want to know if it is possible to define the intervals of time explicitly windows Task Scheduler. I also want to know if we can choose a custom event if selected the option "when an event is logged. Your help will be very appreciated. Thanks in advance

    Hi SreedeviB,

    You can run a service at regular intervals with the Windows Task Scheduler.

    For more information, you can consult the following articles:

    Windows Vista Task Scheduler

    Schedule a task

    Automate tasks with Task Scheduler

    Hope this information is useful.

  • !!! Help! with the addition of auto webfonts hosted

    I used hosted web fonts self with Muse and they work great. But recently I have big problems with this one I bought new (very expensive) police for a new site, that I am trying. I went through all the appropriate measures to add police, Muse/Typekit approve the police so much that it is ready to use, I type using the new font in Muse and he appears beautifully, publish my site and police back to some horrific research which is NOT EVEN close to the self hosted police, I Muse. Please someone tell me what I'm doing wrong because I did everything what I know how to do and this new police was CRAZY expensive fricken and I don't want to give up on it! Please see attached link and images.

    Home

    Screen Shot 2015-02-20 at 6.47.06 PM.png

    Screen Shot 2015-02-20 at 6.47.15 PM.png

    Screen Shot 2015-02-20 at 6.47.26 PM.png

    Screen Shot 2015-02-20 at 6.46.50 PM.png

    Screen Shot 2015-02-20 at 6.47.57 PM.png

    Hey rogert97512532!

    I discovered that my WOFF file was corrupt society I bought my policy through. Corruption comes from the data in the WOFF file then muse he will see in valid WOFF format but the internet and browsers are not. So we will be able to see what works well in the pages of real muse generator, but once it goes live, browsers can figure out what to do with the corrupted file, then they we default back to Georgia instead. If you send the company that you have obtained your policy of they will usually give you another copy of the WOFF who is not corrupt. For future assistance with this, you can use this link ( WOFF Validator ) to check your WOFF files. I hope this helps! Feel free to me message if you have any other questions!

    -Adam Pavis

  • tool how can I define culture fixed size in pixels of the cultures

    Hello

    I use PhotoShop output CC 2015.0.0.  Quite often, I export a bitmap (bmp) from another application.  I then open in PhotoShop and trimming to get the size I want, in my current project is 1024 pixels wide by 350 pixels high.  I normally repeat this process several times.  Whenever I open a bitmap newly exported in PhotoShop, my area of culture begins with bigger that I want it, and I have to drag the edges to the size I want.  I wish that I could either to the exact size of type (1) of the area of the cultures I want in pixels or better yet (2) create a crop 'preset' box I can use over and over again with the pixel dimensions I want.


    I was not able to understand how do either of these things.  In attempting to (1), I chose 'W x H x résolution' and entered my desired width and height, in pixels, but it has not changed my culture area.  In wanting to create a preset, I did manually drag the edges of the acreage for the size I want and then chose "New crop Preset" and he gives a name, but when I change the size of the crop manually, hoping that I can return to my desired culture zone by choosing my preset, it does not either.


    If someone can tell me if/how I can do what I want, I would appreciate it.


    Thanks in advance,

    Paul

    The pixels that disappears when zooming in will soon be corrected in the next update. The other option for something that size would create a form of rectangle to a fixed rate of size, when you get positioned TI ctrl - click on its thumbnail to create selection and harvest.

  • Connection pool with the OAS and the optimal value of min/max

    Hello world


    I have ", works with admin app to implement under oracle application server connection pool. The current value is min = 0, max = unlimited which I think means not implemented connection pool.

    Anyway I don't have a lot of information on connection pooling, I searched the forums, but I'm not able to find any useful information.


    My Manager would like to know what is the optimal value for min/max for the database, is there a specific formula or a tool that can help me on this issue?


    Thanks in advance.

    Hello

    It's a specific formula or a tool that can help me on this issue?

    The value that you specify for the number of connections and connections Min depends on a combination of factors, including the size and configuration of your database server and the type of the SQL operations that
    your application runs.

    For connection pooling,.
    First, check what is the value of 'process' located on the end of DB (for your current value, check v$ resource_limit at the end of db)...
    for example if the process is set to "1000", you cannot set the maximum value of the connection pool to the end server application above 1000 it will crash your database.

    now on the server side Application.
    As a best practice, set the maximum number of open connections and Minimum of connections open to the same value.

    For more details on connection pool and its settings.
    Check "Setting Up Data Sources - Performance Issues" of the link pdf below

    docs.oracle.com/cd/B14099_19/core.1012/b14001.pdf

    Hope that it would be useful

    Concerning
    Fabian

  • Is it possible to prevent the 'threading' messages with the same subject all Thunderbird?

    Now Thunderbird seems to clump messages with the same subject and there is a graphic ligature tying these together. Would be nice if I could disable this feature. It is generally more useful if a repertoire of messages appear in reverse order of date or another order I specified when sorting. "Threading", if I can call it that, defeated my sort order.

    It would be nice if I could turn the feature occasionally to discuss a conversation, but for day to day use, I want to turn it off.

    Thank you.

    I believe that this is the setting that you are after:

    https://support.Mozilla.org/en-us/KB/configuration-options-viewing-messages#w_specify-whether-messages-in-the-message-list-are-grouped-into-threads

    See you soon,.
    Dave

  • Embedded audio player doesn't work with Firefox in a laptop computer, but works fine on a PC. How can I fix? It started with the new design of Firefox.

    This problem apparently only occurs with the audio player built into http://www.theskepticsguide.org/ . I tried other embedded audio players from other websites and they work fine. In the Firefox installed in my laptop, no matter what I do it does not play the SGU podcast. When I try to click on the download option it says "Video cannot be read because the file is corrupted. However, I can play and download the podcast without any problem with Firefox installed in my PC, which is the exact same version that is in my laptop, so I don't really know what could be the cause.

    I remember that this was not the case before the new design of Firefox. I tried the solutions proposed on this problem before asking this question. I checked that the plugins are up-to-date. I removed all the addons and plugins, and this did not help either. Firefox reset with no luck. Also tried a fresh install of Firefox and it didn't work. I used the laptop without synchronization first, and then synchronize with no difference. Flash is up to date and there is no apparent problems there.

    Maybe it's a codec missing or damaged? I wouldn't trust codecs from sources other than Microsoft for this purpose, since Firefox tries to use Windows to read the file.

    If you decide to give up and around the native player for a plugin, these changes of settings usually work for this:

    (1) in a new tab, type or paste Subject: config in the address bar and press ENTER. Click on the button promising to be careful.

    (2) in the filter box, type or paste media and make a pause so that the list is filtered

    (3) [except XP], double-click on media.windows - media - foundation.enabled to change its value from true to false.

    (4) double click on media.directshow.enabled to change its value from true to false.

  • buffer size and sync with the cDAQ 9188 problems and Visual Basic

    Hi all, I have a cDAQ-9188 with 9235 for quarter bridge straing caliber acquisition module.

    I would appreciate help to understand how synchronization and buffer.

    I do not use LabView: I'm developing in Visual Basic, Visual Studio 2010.

    I developed my app of the NI AcqStrainSample example. What I found in the order is:

    -CreateStrainGageChannel

    -ConfigureSampleClock

    -create an AnalogMultiChannelReader

    and

    -Start the task

    There is a timer in the VB application, once the task begun, that triggers the playback feature. This function uses:

    -AnalogMultiChannelReader.ReadWaveform (- 1).

    I have no problem with CreateStrainGageChannel, I put 8 channels and other settings.

    Regarding the ConfigureSampleClock, I have some doubts. I want a continuous acquisition, then I put the internal rate, signal source 1000, continuous sample mode, I set the size buffer using the parameter "sampled by channel.

    What I wonder is:

    (1) can I put any kind of buffer size? That the limited hardware of the module (9235) or DAQ (9188)?

    (2) can I read the buffer, let's say, once per second and read all samples stored in it?

    (3) do I have to implement my own buffer for playback of data acquisition, or it is not necessary?

    (4) because I don't want to lose packets: y at - it a timestamp index or a package, I can use to check for this?

    Thank you very much for the help

    Hi Roberto-

    I will address each of your questions:

    (1) can I put any kind of buffer size? That the limited hardware of the module (9235) or DAQ (9188)?

    The samplesPerChannel parameter has different features according to the synchronization mode, you choose.  If you choose finished samples the parameter samplesPerChannel determines how many sample clocks to generate and also determines the exact size to use.  But if you use streaming samples, the samplesPerChannel and speed settings are used together to determine the size of the buffer, according to this excerpt from the reference help C DAQmx:

    Note that this buffer is a buffer software host-side.  There can be no impact on the material available on the cDAQ-9188 or NI 9235 buffers.  These devices each have relatively small equipment pads and their firmware and the Driver NOR-DAQmx driver software transfer data device to automatically host and the most effective way possible.  The buffer on the host side then holds the data until you call DAQmx Read or otherwise the input stream of service.

    (2) can I read the buffer, let's say, once per second and read all samples stored in it?

    Yes.  You would achieve this by choosing a DAQmx Read size equal to the inverse of the sampling frequency (during 1 second data) or a multiple of that of the other playback times.

    (3) do I have to implement my own buffer for playback of data acquisition, or it is not necessary?

    No, you should not need to implement your own stamp.  The DAQmx buffer on the host side will contain the data until you call the DAQmx Read function.  If you want to read from this buffer less frequently you should consider increasing its size to avoid the overflow of this buffer.  Which brings me to your next question...

    (4) because I don't want to lose packets: y at - it a timestamp index or a package, I can use to check for this?

    DAQmx will meet you if all packets are lost.  The default behavior is to stop the flow of data and present an error if the buffer of the side host DAQmx overflows (if, for example, your application does not pick up samples of this buffer at a rate equal or faster than they are acquired, on average).

    If, for any reason, you want to let DAQmx to ignore the conditions of saturation (perhaps, for example, if you want to sample continuously at a high rate but want only interested in retrieving the most recent subset of samples), you can use the DAQmxSetReadOverWrite property and set it to DAQmx_Val_OverwriteUnreadSamps.

    I hope this helps.

  • How to set the size of text with the report generator

    Hello.

    I'm trying to set the size of the text with the report generator, but I find that I can't do this. Here is an example of the code that I use. Can someone tell me what I'm doing wrong please?

    Thank you, Alec

    I was generation from a word template.

    I hacked my version of the Toolbox to give me maunal indicator control "model? He had obtained his permenatly self stuck on "T". I exposed this flag outside the API, so I can control under certain weather conditions I may or may not use the model police.

    Does anyone know how to use this toolkit, or I did the right thing?

    Cheers, Alec

  • Fix it fails Center with the error: unable to get the catalog of the troubleshooter. Error MatsGetSapCatalog failed

    Original title: Fix it center fails.

    Difficulty Center fails with the error:
    Unable to get the catalog of the troubleshooter. Error MatsGetSapCatalog failed
    I can't find the url of re - download.
    It doesn't seem to be at the Download Center.
    Thank you
    Frank C

    Vista Ultimate 64 bit sp2

    CF. http://answers.microsoft.com/en-us/protect/forum/mse-protect_scanning/scanning-engine-has-stopped-responding/e0f84bec-2555-4279-bfb7-aff691b8ba8d

  • MY FONT SIZE HAS CHANGED WITH THE LAST UPDATE AND I CAN'T SEEM TO RETURN TO NORMAL.

    WITH THE LAST UPDATE OF THE FONT SIZE CHANGED ON MY EMAIL ACCOUNTS AND PAGES OF MY WORK.  IT OF SMALL, I CAN'T READ IT EVEN WITH GLASSES ON. IT IS MAGNIFIED 150 TIMES.  MY COMPANY, HE CHANGED THE RESOLUTION WHICH HAS CHANGED MY SIZES OF ICONS, BUT DOESN'T HAVE ANYTHING DONE TO MY FONT SIZES.  THE HAD ME ALSO DO SOMETHING WITH MICROSOFT THAT DOESN'T WORK ANYMORE.  SO THEY HAD ME CONTACT MICROSOFT WHO CAN HELP ME BECAUSE I CAN'T AFFORD TO PAY TO GET ANSWERS TO MY QUESTIONS.  I AM ALREADY 3 HOURS LATE FOR WORK IN TRYING TO SOLVE THIS PROBLEM.  CAN SOMEONE OUT THERE HELP ME?

    Hi ELLA SMITH (KELLY).

     

    Welcome to the Microsoft community forums. Please post your query and giving me the opportunity to help you.

    I'm sorry for the inconvenience caused.

    I will guide you on the issue of the police.

    (1) you are on a domain network?

    (2) the Windows updates were installed?

    (3) what happens when you try to change the font sizes, you get an error message?

    I suggest you refer to the link to verify that Windows update have been installed.

    http://Windows.Microsoft.com/en-us/Windows-Vista/see-which-Windows-updates-are-installed

    Method 1:

    You can check follow them the links below, if that helps:

    (1) change the Windows fonts

    http://windowshelp.Microsoft.com/Windows/en-in/help/bdc9d003-777b-4B1E-9664-2957f50870bd1033.mspx

    (2) fonts: frequently asked questions

    http://windowshelp.Microsoft.com/Windows/en-in/help/0caf0419-6990-45de-8D71-67f14a3ae4c71033.mspx

    (3) how to repair the operating system and how to restore the configuration of the operating system to an earlier point in time in Windows Vista

    http://support.Microsoft.com/default.aspx/KB/936212

    Method2:

    un) make system restore, choose the date where the screen resolution and the fonts were ok as your restore point.

    (b) when these updates come to install again, do only ONE AT A TIME. After each installation, check if the screen is ok, and then next update and so on.

    c) in this way, you'll be able to simply update is the cause of this problem.

    If the problem persists feel free to post us. We're here to help.

    Thank you.

Maybe you are looking for

  • saving and recalling Panel configuration on FPGA

    First of all, I'm a first time Labview user.  The application is an FPGA on a surfboard OR-9146. My question is, I want to save the settings of front panel, when I exit the application, and then remember them the next time the application is started.

  • QuickBooks 2001 Version has stopped working Windows Vista

    Two days ago, when I tried to open Quickbooks 2001 (I have Windows Vista), a pop up came 'QB has stopped working.  A problem caused the blocking of the program works correctly.  Windows will close the program and notify you if a solution is available

  • BlackBerry Z10 bad e-mail address and password

    I keep getting these requested updates of Blackberry id recently and I need ot legeremnts my password etc. However, I do not remember my word password so tried the password reset only to find out that the email I entered when I orginally had the phon

  • Recovery partition using too much space?

    I recently bought a laptop refurb that has a recovery partition of 13.67 GB as shown in the Windows disk management.  When I check the properties of the partition it shows 8.42 GB of used space and 5.24 GB of free space.  Is there anyway that I can a

  • VPN concentrator, 3510

    Is there a Macintosh Cisco VPN client for use with a 3510 hub?