Combining the fixed and cached thread pools

Is there a way to 'combine' the behavior of cached and fixed thread pools ? I have a requirement where
- at startup, I need to execute a fixed number of short-lived tasks at the background
- after startup, on demand, I need to run one short-lived task at a time
If I use a fixed thread pool for my startup processing, it creates the fixed number of threads to process the tasks. But subsequently, those many threads are not required since my task submission is going to be one at a time. The remaining (n-1) threads therefore are really sitting idle & useless.
If I use a cached thread pool, then I cannot constrain the number of threads to run at startup (since it creates one for each task). Though it ends up taking those threads out after they are idle for a fixed period. But I'm worried that it might create many threads and possibly slowing down the startup ?
Is there a way to create a pool with a fixed number of threads but 'remove' a set of threads when they are idle ?
TIA

v_bala wrote:
Thanks. The SynchronousQueue worked as expected. But I tried a LinkedBlockingQueue with size 1 hoping that would cause the second task submission to cause a new thread creation. It didn't. Instead it queues up the request (maybe the doc in ThreadPoolExecutor says that when it mentions "If corePoolSize or more threads are running, the Executor always prefers queuing a request rather than adding a new thread"). I suppose if I were to try another it would create another thread ? (I was testing with only two tasks - the first one ended up creating a thread for the task and the next got queued since the queue capacity is 1)yes, the TPE will not start adding threads until the queue starts rejecting them. kind of odd in my opinion, but that's how it works.
Btw, that was an interesting idea to add a task that scale the core pool number down ! Currently it comes back down to just the one thread (my core pool size is one) after the idle timeout but your idea may give me a slightly better response since it will scale down the core pool size quicker....I suppose if there was a task submission before that idle time there maybe a performance hit (but I don't anticipate that in my case )?actually, that won't scale things down any faster. changing the core pool size will not ditch the other threads immediately, they will still stick around until they idle timeout. changing the core pool size allows you to not worry about the queue implementation (the first solution). you can set the initial core pool size to your "max" size on startup, then drop it down for the normal processing, all the while using a linkedblockingqueue of unlimited size.

Similar Messages

  • Budget Report to show the fixed and variable split for Materials

    Hello Gurus,
    Could you tell me if there is a budget standards report that will show the fixed and variable split for Materials? Example: Labor, Equip., QC and Overheads? 
    I need it for the correctly rolled-up 'final material number' step.  The report that does this now (without fixed and var split) is the Indented BOM Comparison (sret - cost mgmt-product costing - cost mgmt-customized reports - cost estimate comparison - costed multilevel compare rpt - Indented BOM Comparison).
    Thanks,
    Jefferson

    one simple way is in your final itab declare a slno type i field
    data : begin of itab occurs 0,
    slno type i,
    <other fields>
    end of itab.
    after filling the data in itab.
    loop at itab.
    itab-slno = sy-tabix.
    modify itab.
    endloop.
    in fieldcatalog also you have to define that slno field as the first column.
    but it will change its order if you are sorting the output or filtering the output.
    regards
    shiba dutta

  • Can someone help me when Firefox closes randomly it removes all the cookies and cache, and I am not able to restore lost tabs...?

    For a while now Firefox has randomly shut down for reasons unknown. Sometimes windows reports the error but not always. When I start Firefox back up again, it does not restore my tabs. Also as an added bonus it deletes the cookies and cache, and I don't know why. Furthermore this occurrence has become more and more frequent. Just in the last hour along before writing this complaint, Firefox crashed three times right as I switch users, but not every time I switched. I am a taboholic, addicted to tabs, sometimes 70+, and this is the final straw. This frequency became more and more prominent a few days ago. When it first crashed, Windows was kind enough to let me know of the error which first occurred one to two weeks ago. It has become the very bane of my internet surfing. Someone please help, or I will have to renounce my allegiance to Firefox and switch to the dark side that is Crome.

    <blockquote>... or I will have to renounce my allegiance to Firefox ...</blockquote>
    There is no citizenship oath involved in using Firefox, it's a piece of software.
    Look, if Firefox isn't generating any crash reports, you more than likely have an operating system or hardware issue. If Firefox is generating crash reports you can retrieve that information and post the report numbers here.
    https://support.mozilla.com/en-US/kb/Firefox+crashes#Getting_the_most_accurate_help_with_your_Firefox_crash
    Type '''about:crashes''' in the URL bar and hit Enter.
    Click the hyperlinks to bring up the Crash Report pages and copy'n'paste the URL of each of those reports into the message box here. We'll see if we can help you figure out what is causing those crashes to happen.

  • Combine the output and make the sum by article

    In our company we have a lot of small orders (the customer orders every day the same articles) ->
    we make just one bill at the end of the month.
    Most customers don't wont the detail (to much paper) and therefore we have for the bill the possibility to just make the total bill (total per article...).
    so we design the two print program (global bill) and (detail bill) to output RD00,
    when we create a "Credit notes" for such a bill, we will get a  huge amount of paper (output type = BA00) -> so the question was if there was a standard program to combine the output and make the sum by article...
    Thanks.

    A custom print program is what u need, what u can do is create a report program which takes input all the articles ( a range thru selection screen wud do) and then calculate their sum or whatevr according to ur requirement and collate them into an internal table and output a script form thru the report itself, so no need to attach output type and all that.
    кu03B1ятu03B9к

  • 2nd loop  combined the first and second statement lines...why?

    I wrote this program to calculate the price. I want to have users to enter the item name and price continuesly, then once the hit 'f', it will give them the total. I was able to enter the first item and price but then the second time around, this is what show on my screen:
    Item to purchase (enter F when finished): price for this is:
    It combined the first and second lines in one line. I can't figure out why.
    Please help.
    This is part of my code below:
    for (;;)
    String F ="F";
    System.out.print("Item to purchase (enter F when finished): ");
    item=sc.nextLine();
    if(item.equalsIgnoreCase (F))break;
    System.out.print("Price of this "+ item +" is: ");
    price=sc.nextDouble();

    Insert a sc.nextLine(); before the nextDouble.
    And insert a "\n" at final of System.out.print string.
    for (;;)
    String F ="F";
    System.out.print("Item to purchase (enter F when finished): \n");
    item=sc.nextLine();
    if(item.equalsIgnoreCase (F))break;
    System.out.print("Price of this "+ item +" is:\n ");
    price=sc.nextDouble();
    sc.nextLine();
    }

  • Every time I try to install Adobe Reader, I get error message "object already installed". Tried all the fixes and suggestions.

    Every time I try to install Adobe Reader, I get error message "object already installed". Tried all the fixes and suggestions. I need help.

    If you haved tried all the fixes and suggestions, there is not much to add. Just in case: did you really try using this tool http://labs.adobe.com/downloads/acrobatcleaner.html to first eliminate all traces of Reader, and then use the full offline installer from http://get.adobe.com/reader/enterprise/?

  • Iphone camera is not combining the light and dark photos but is presenting them as separate photos

    Hello Community,
    My friend showed me his iPhone 4 today and every time he takes a photo a dark version and a lighter version are shown, not combined as one but as two separate photos. I believe I remember that the camera takes more than one shot and combines the best of both, his camera is not combining them. How do instruct him to fix this problem?
    Thank you for any help,
    Nick M.

    Hello,
    And thanks for your time.
    Am I understanding you correctly, that it is normal for there to be two photos, one dark and one light?
    Nick M.

  • Java 7 release 25 will not work on Firefox 22 -- tried all the "fixes" and it works in IE and Chrome. What now?

    The newest release of Java (7.0.250) simply will not run on Firefox 22. I have tried all the "fixes" posted on the Mozilla site -- enabled in both the browser and the Java control panel. The new release of Java works just fine in IE and Chrome.

    Hello,
    Certain Firefox problems can be solved by performing a ''Clean reinstall''. This means you remove Firefox program files and then reinstall Firefox. Please follow these steps:
    '''Note:''' You might want to print these steps or view them in another browser.
    #Download the latest Desktop version of Firefox from http://www.mozilla.org and save the setup file to your computer.
    #After the download finishes, close all Firefox windows (click Exit from the Firefox or File menu).
    #Delete the Firefox installation folder, which is located in one of these locations, by default:
    #*'''Windows:'''
    #**C:\Program Files\Mozilla Firefox
    #**C:\Program Files (x86)\Mozilla Firefox
    #*'''Mac:''' Delete Firefox from the Applications folder.
    #*'''Linux:''' If you installed Firefox with the distro-based package manager, you should use the same way to uninstall it - see [[Installing Firefox on Linux]]. If you downloaded and installed the binary package from the [http://www.mozilla.org/firefox#desktop Firefox download page], simply remove the folder ''firefox'' in your home directory.
    #Now, go ahead and reinstall Firefox:
    ##Double-click the downloaded installation file and go through the steps of the installation wizard.
    ##Once the wizard is finished, choose to directly open Firefox after clicking the Finish button.
    Please report back to see if this helped you!
    Thank you.

  • How can I combine the audio and video files from youtube downloads when they don't automatically combine?

    I'm using YouTube Video and Audio Downloader. Sometimes the audio and video files combine automatically, sometimes they don't - remaining as separate " DASH - .m4a and DASH - .mp4 ". It used to be that when this would happen I could open up a "ffmpeg" window which would allow me to "manually" convert them to a combined .mp4 file. It was a "drag and drop" type of interface. For some reason I can no longer access that ffmpeg combining function. I tried clicking on ffmpeg.exe. I tried re-downloading ffmpeg several times, both from the Downloader options tab and from the ffmpeg website.
    Thanks for your help.

    Sounds like a question for the developer of the video download add-ons that you have installed.

  • Read the fixes and still having problems. Firefox will not open at all and I receive a crash report upon launch. Have restarted, shut down, run virus and malware checks and even tried downloading and reinstalling with no response. Please assist.

    Read the fixes. Cannot open Firefox in safe mode. Have tried reinstalling Firefox. Crash occurs each time I try to launch Firefox. Have run scans, checked for malware, spyware, installed all windows updates and still no luck.
    Have accessed my crash reports. One of the reasons indicated is:
    GenuineIntel family 6 model 23 stepping 10
    Crash Reason
    EXCEPTION_ACCESS_VIOLATION_WRITE
    Have no idea how to fix this and have had crash reports since yesterday evening.
    Signature: nsStandardURL::SchemeIs(char const*, int*)

    Sorry believe something got miscommunicated. Wasn't trying to qualify firefox as malware - was terming it that way because the malware was crashing Firefox and no other issue. Worked on it and had isolated the virus in avast (put it in the chest) and was searching for assistance on why even after isolating the virus and restarting (some forums had indicated to then uninstall and reinstall Firefox, which I did), still would not launch without the crash report.
    Worked the problem and eventually installed a 5.0 version of Firefox and it launches. Only seems to have the crash report with 6.0 or higher.
    The forums had suggested that if after isolating the malware in avast or disinfecting it with MBAM (tried that too), to uninstall and then reinstall the latest version of firefox. That's when I tried the older versions. Had run a boot log scan as well and didn't see any additional problems. Just can't launch in 6.0 or higher.

  • JRE Cache ignores the "Expire" and "Cache-Control: no-cache" directives.

    My applet is using HttpURLConection to retrieve data from a server with Caching enabled. The cache contents are "revalidated" (via "if-modfied-since") each time the applet is started. However, subsequent requests to retrieve the same resource are always read from the cache with no validation even if the resource has expired.
    The server is sending a valid "Expires:" tag and "Cache-Control: no-cache" tag in the response; but, the JRE refuses to recheck for an updated version of the resource even after the file has expired.
    The JRE does seem to understand the "Cache-Control: no-store" tag; but, this is inefficient (no caching at all) when I'm tring to get it to not refetch the resource unless there's a change. Is there some other tag that the JRE is expecting to see?

    I have a similar problem except that I want my pages to not cache at all. The server is setting the Cache-Control: max-age to 0 and the Expires to "now" but JRE seems to ignore these settings, but only sometimes. Sometimes pages are fetched from cache and sometimes from the server.
    In my applet I'm using a normal URLConnection like this:
    URLConnection uc = new URL("http://<server>/method").openConnection();
    uc.connect();
    InputStream is = uc.getInputStream();
    is.read();When my request headers look like this:
    accept-encoding: gzip
    Host: <server>
    Cache-Control: no-cache
    Pragma: no-cache
    User-Agent: Mozilla/4.0 (Windows XP 5.1) Java/1.6.0_13
    Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Connection: keep-alivethe page will not be cached and is requested again but this time without the accept-encoding, Pragma and Cache-Control. The adding (and removal) of the headers seems to happen inside the JRE, though. I'm not explicitly setting them.
    The response header of the first request looks like this:
    HTTP/1.1 200 OK
    Date: Wed, 20 May 2009 12:55:07 GMT
    Server: Apache/2.2.11 (Win32) mod_jk/1.2.26 PHP/5.2.8
    Cache-Control: max-age=0
    Expires: Wed, 20 May 2009 12:55:07 GMT
    Vary: User-Agent,Accept-Encoding
    Content-Encoding: gzip
    Keep-Alive: timeout=120, max=79
    Connection: Keep-Alive
    Transfer-Encoding: chunked
    Content-Type: text/html;charset=iso-8859-1When the request is made with this header:
    User-Agent: Mozilla/4.0 (Windows XP 5.1) Java/1.6.0_13
    Host: <server>
    Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Connection: keep-aliveThe response headers looks like this:
    HTTP/1.1 200 OK
    Date: Wed, 20 May 2009 12:55:07 GMT
    Server: Apache/2.2.11 (Win32) mod_jk/1.2.26 PHP/5.2.8
    Content-Length: 1016
    Cache-Control: max-age=0
    Expires: Wed, 20 May 2009 12:55:07 GMT
    Vary: User-Agent,Accept-Encoding
    Keep-Alive: timeout=120, max=83
    Connection: Keep-Alive
    Content-Type: text/html;charset=iso-8859-1And in this case the JRE sometimes fetches the request from the server and sometimes from cache. I have not been able to determine how the JRE decides to refresh, or why it sometimes sends an accept-encoding and Pragma header and sometimes not.
    any help would be appreciated.
    Alex

  • OAAM: Combining the Username and Password page?

    Hi,
    I am currently working on OAAM 11g. Is it possible to combine Username page and password page?
    As of now first we enter the username, OAAM fingerprints the device and then displays the password page.
    Also Is it possible to have only a text field for password rather than having a textpad/pinpad or anything?
    Thanks,
    Pradeep

    Hi Pradeep,
    Were you able to find a solution for this? I am trying to implement a similar login page and any information you provide will be very helpful.
    Thanks,
    N

  • Can you mix calls to the Posix and native thread librariess?

    Is it possible to mix calls to different thread libraries within the same process.
    We have a shared library interface to our product which is called from a customers application. In order to provide a thread safety we need to protect global data in this library with a mutex. However we do not know which thread library (if any) will be used by the calling application.
    If we used a Posix mutex in our library would it work if the calling application was implemented using non-Posix threads?
    Are the Posix and Solaris thead header files different interfaces to the same underlying implementation?
    What overheads are there loading the thread library when it is not needed? If for example the calling application was implemented without using threads.
    Would we have to test our interface with the different thread implementations available? eg /usr/lib/lwp/libthread.so, /usr/lib/sparcv9/libthread.so as well as /usr/lib/libthread.so.

    I know the author of the original post wrote this long ago, but I thought I'd write a reply in case anyone else stumbles on this like I just did.
    Is it possible to mix calls to different thread
    libraries within the same process.Yes. Though you have to be careful about compilation and link flags, and the order of libraries specified on the link command-line (-lpthread and -lthread). For complete information, refer to the Solaris "Multithreaded Programming Guide", available at http://docs.sun.com in the the Solaris 8 (or whatever version) Software Developer Collection.
    If we used a Posix mutex in our library would it work
    if the calling application was implemented using
    non-Posix threads?Yes.
    Are the Posix and Solaris thead header files different
    interfaces to the same underlying implementation?Yes, I believe so. POSIX specifies an interface. I think the Solaris threads implementation was part of the Solaris OS before pthreads were supported on it. Anyway Solaris really uses "LWPs" (Lightweight Processes) at the kernel level, and user-level threads (POSIX or Solaris threads) are mapped onto LWPs.
    What overheads are there loading the thread library
    when it is not needed? If for example the calling
    application was implemented without using threads.You should never link to the thread library when it is not needed. It results in unnecessary overhead. This is documented in the book mentioned above.
    Would we have to test our interface with the different
    thread implementations available? eg
    /usr/lib/lwp/libthread.so,
    /usr/lib/sparcv9/libthread.so as well as
    /usr/lib/libthread.so.I don't think so, but judge for yourself; I suspect if any inconsistent behavior is found it will have more to do with defects in these implementations than in your own code. On Solaris 8:
    - /usr/lib/libthread.so is the default Solaris threads library that does a many-to-many mapping of user-level threads to kernel-level-lwp's
    - /usr/lib/lwp/libthread.so is the "alternate" Solaris threads library that does a 1-to-1 mapping of user-level threads to kernel-level-lwp's
    - /usr/lib/sparcv9/libthread.so I think is the fully 64-bit version of the default libthread
    Hope this helps somebody.

  • I have iTunes on 2 PC's. Somehow I wound up with 2 Apple ID's. I would like to combine the music and apps under one ID so that I can synch with my iPhone 4 and iPad. Can this be done?

    I had a WIndows XP desktop and Laptop. Each had iTunes installed. When moving from iPhone 3 to 4, I acquied a second Apple ID. I want to migrate all of my playlists, downladed songs, podcasts and apps to my new sesktop (HP 64-bit, WIndows 7) and make that my headquarters for iPhone and iPad 1. Is it even possible to combine my media and get it together on my hand-elds? If yes, please enlighten. Thanks in advance.

    I think I will do this.  I will use my apple ID and set face time and message to work independently.  That solves one problrem.  My other problem and maybe my bigger problem is that if I am using my apple ID, how do I iflter all of this so that my kids don't see my contacts, get my apps, etc. ?

  • Firefox won't open. Tried all the fixes and still no fix. Crash code is fefc6b11-303e-4e33-85f0-412e52110206. Please help if you can.

    Firefox tries to open but all that comes up is the Mozilla Crash Reporter and can't open past this point.

    Do a clean (re)install:
    * Download a fresh Firefox copy from http://www.mozilla.com/firefox/all.html and save the file to the desktop.
    * Uninstall your current Firefox version and remove the Firefox program folder before installing that copy of the Firefox installer.
    * Don't remove personal data if you uninstall the current version.
    * It is important to delete the Firefox program folder to remove all the files and make sure that there are no problems with files that were leftover after uninstalling.
    See:
    * [[Basic Troubleshooting]]

Maybe you are looking for

  • Pass unicode data in SQL Server 2008 stored procedure parameter

    Hi, I want to pass unicode data in a SQL stored procedure. But I am not sure that how to append N with NVarchar datatype. For example I Create a table LocalizationTest and wants to insert a few records. Create table LocalizationTest     Field1 NVarch

  • Bluetooth not connecting

    SInce the 8.02 update my Bluetooth no longer works in my van. It connects and disconnects intermittently. As a handicap person I find it not only frustrating but dangerous. My call will not always connect and hangs up in mid conversation. That is whe

  • Can SMD be setup to monitor the Managing System?

    Hello, We have been working off and on for the last few months installing Wily Introscope, which in turn required E2E RCA, which in turn required SMD to be installed.  Since virtually all of our systems are on a relatively low pl of the kernel, 114,

  • Wifi unable to connect to network on IOS 7.1

    I m using iphone 5s and recently updated my ios to 7.1. My wifi at office which i was able to connect to earlier is not able to connect now after the update.On the other hand, it works well with my wifi at home and anyother place. I am facing this pr

  • Feature Suggestion - Playing Unplayed Podcasts

    With several different Podcast subscriptions and multiple episodes per, it would definitely be nice to click the play button on the "Podcasts" menu option and play all unplayed Podcasts. I find I have to use a smart playlist for unplayed Podcasts to