Limit the number of threads

Hello,
I am developing an application which has to execute untrusted Java source code. The Java security manager is helpful in preventing unauthorized network and local file system access, but as far as I can tell, it can not limit the number of threads created by the untrusted application.
How would I limit the number of threads an untrusted Java application is allowed to create?
Jure
Edited by: zbontarj on Feb 16, 2009 9:46 AM

zbontarj wrote:
Create a custom ThreadGroup will allows only a limited number of threadsI can't see any methods in ThreadGroup that limit the number of threads. There is a method that returns the number of active threads in the group, but that doesn't help me out much.ThreadGroup is not designed for easy extensibility.
You can either take a copy and modify it to take a thread limit. (You can override the default implementation by using -Xbootclasspath/p:path or adding a jar to lib/endorsed however this may contravene the JDK license.)
Or you can write a thread which monitors threads in the thread group every few seconds.
Or you can use the SecurityManager to check the threads in the thread group. The SecurityManager is called each time a thread is added and it can check the threads in the current thread group.

Similar Messages

  • Is there any way to limit the number of Threads running in Application(JVM)

    Hello all,
    is there any way to limit the number of Threads running in Application(JVM)?
    how to ensure that only 100 Threads are running in an Application?
    Thanks
    Mohamed Javeed

    You should definitely use a thread pool for this. You can specify maximum number of threads that can be run. Be note that the thread pool will only limit the number of threads that are submitted to it. So donot call "Thread"s start() method to start thread on your own. Submit it to the pool. To know more, study about executor service and thread pool creation. Actually it will not be more than 20 line code for a class and you might need maximum of 2 such classes, one for threadPool and other one for rejection handler (if you want).
    Just choose the queue used carefully, you just have to pass it as a parameter to the pool.
    You should use "Bounded" queue for limiting threads, but also be careful in using queues like SynchronizedQueue as the queue will execute immediately the threads submitted to it if maximum number of threads have not been running. Otherwise it will reject it and you should use rejection handler. So if your pool has a synchronized queue of size 100, if you submit 101th thread, it will be rejected and is not executed.
    If you want some kind of waiting mechanism, use something like LinkedBlockingQueue. What this will do is even if you want 100 threads, you can specify the queue's size to be 1000, so that you can submit 1000 threads, only 100 will run at a time and the remaining will wait in the queue. They will be executed when each thread already executing will complete. Rejection occurs only when the queue oveflows.

  • HT201320 How do I limit the number of emails in ios7? On older software I could limit mail to 50 or so.

    I have thousands of email in my Verizon account. Now that I've upgraded to ios7, they're all stored on my phone and it keeps locking up. In older versions of the software I could limit the number of emails on my phone. I can't find that setting in ios7. Any ideals?

    Thanks, but issue of pain for me is on opposite side, as per thread above:
    I do not want so many emails stored on iPad storage.
    All I want to be able to limit emails stored to, say, last 3 days.
    If older emails are available available only via search on server , I am fine that.
    With this change in iOS7 Apple undertook shameless effort to press users to buy more expensive higher strife devices, and for sooner depreciation of previous line of models.

  • How to limit the number of builds in tfs build queue

    Hey.
    I have a problem, i want to limit the number of requests for build that developers can trigger with gated check-in's.
    More like this, i have my developers and they trigger 10 builds , and 10 is my limit , so when another developer preform a gated check-in I want tfs reject that request and send a mensage to the developer saying something like this "you can't queue
    more builds, wailt until queue is free".
    Anyone know how to do that?
    Thanks,

    Hi Jptfc,
    For your situation, you can check whether it is possible to set themaximumnumber or concurrently running buildsin parallel on the Build Controller. Then multiple builds can be built concurrently, and the queued builds number will be not lessin the meanwhile.
    Check this
    thread for more informaiton.
    If you want tfs reject request and send a mensage to the developer when the queued builds number equals the limit, maybe you can use Visual Studio
    extention
    . I don't have tried with it, and you can try it on your test server. Or you can open a new thread in Visual Studio Integrate forum for a better response.
    Best regards,

  • How do you limit the number of emails that download in ios7?

    How do you limit the number of emails that download in iOS7? In previous versions, I was able to limit (i.e. 50/100/ etc), the number that would download to my phone at any given time - other than new emails. Past/old emails would only be reloaded if I deleted newer ones or I requested more be loaded.

    Now solved:
    https://discussions.apple.com/thread/5325394?tstart=0
    Guy in my thread fixed it for me. Very simple to do.

  • How do I limit the number of Operator Interface and Execution instances to one?

    We have a problem in MFG.  The operator launches to instances of the operator interface and executes the same sequence.  A second scenario is where the operator is executing the sequence and then changes from the execution window back to the Sequence Display window and launches a second execution window.  We need to understand how to limit the number of executions within an instance of the Operator Interface to one.  We also need to understand how to limit the number of instances of the Operator Interface to one.
    Regards,
    Steve Easthope

    Steve,
    This is a duplicate post.  Please reference your first thread. 
    Derrick S.
    Product Manager
    NI DIAdem
    National Instruments

  • How can I limit the number of attempts to print a web page

    Hi I'm trying to find a resolution for an issue on our network.
    We run several kiosk machines that allow customers to print out documents and web pages. However we are finding that we waste a lot of ink due to user's frequently sending the same print task to the printers.
    Just yesterday we had someone print out over 70 pages because they just keep clicking print.
    I've tried looking for an add-on that would address this but was not able to find one.
    My question is this, Is there an internal setting that can be changed in firefox to limit the number of print attempts to say once every 30 seconds, or even a way to make a dialogue box come on screen saying that the print request is currently processing and not allow more printing until the current task is completed.

    Sorry, there is no setting within Firefox to prevent that from happening. Once the user sees the "native print dialog" box (what is seen when you do Ctrl + P to initiate printing), the operating system and the printer drivers take it from there.
    I have seen something similar to that on kiosk / rental PC's in FedEx Office stores, that notify the user of the cost per page the user wants to send to a printer, and if the user should happen to click again to print the same pages again it asked if you want to spend another $x.xx to print a second copy. Wouldn't be too much different to just shut off the printing of multiple copies of the same document and notify the user of that action.
    My advice is to discuss that with whoever set up those kiosks to being with.

  • Limit the number of open production order

    Dear PP experts,
    I am working on discrete scenario where client want to limit the number of open production order per work center. The more elaboration is like, for one work center the only specific number of production should remain open (e.g. 5 production order in assembly shop) when user is trying to open 6th production order system should restrict that.
    Does any standard functionality available in system or needs development?
    Regards,
    Shekhar

    Dear,
    You can do it with avilability check for materail and capacity.
    In OPJK do the for your production order type as no release if materail and capacity i missing.
    Hope clear to you.
    Regards,
    R.Brahmankar

  • How to limit the number of rows in a report

    I have several reports with a number of parameters - date ranges etc.
    Depending on the parameter values selected by the user the reports can return thousands of rows.
    I would like to limit the number of rows returned to, say, 500. If more than 500 rows are returned by the query then display an error message requesting that the user enter more specific parameters.
    Ideally for performance reasons it would be good to catch the error before the datafile is generated, but I don't know if this is possible. Alternatively a check in the template might do the job - using COUNT on the group?.

    Hi Hugh,
    In your query, you got to add rowum < 500 or some sort of DB specific limit to the row being returned,
    this will help to stop the report to get more than 500 records and the report template wont have any restriction.
    or
    you can do that in template too, but i would not recommend.
    In these both cases or in any case, you cannot give any meaningful error if it exceeds N rows,there is no option like this till now.

  • How can I limit the number of emails retained on my ipad air?

    How can I limit the number of emails that are retained on my iPad Air?  Because of legal requirements of a long-term project, I cannot permanently delete emails relating to that project from my ISP's mail server.  My gmail account contains over 17,000 emails and, upon setting up my new iPad, and updating to ios 7.1.1, I now have all 17,000+ emails taking up space.  I would like to limit the emails by count as I was able to do on my old iPad running ios 5.1.1 OR to retain them based on date range.  I have not found any instructions on the support discussions or general iPad blogs that allow me to do that.  Any way around this problem?
    I also miss the 5.1.1 mail search feature that allowed me to narrow the search by from/to/subject/all.  Does anyone know if that feature is available using some little-known ios 7.1.1 feature?
    Thanks for your help.

    jlfcba wrote:
    IOS 7.1.1 doesn't show a "days to sync" parameter anywhere in SETTINGS/Mail,Contacts,Calendars/ACCOUNTS/GMAIL Account/ GMAIL Acccount Info.  There is nothing in iTunes relating to such an option either.  So, it seems I'm back to square one.
    If you have a decent mail provider like Microsoft Hotmail or Outlook.com mail it does.
    If you have Gmail it does not.  Quite right. Gmail is rubbish.

  • HT2729 I have limited space on my new ipad. How can I limit the number of songs from my itunes on my imac from going to my ipad when I connect the two?

    I have limited space on my new ipad. How can I limit the number of songs from my itunes on my imac from going to my ipad when I connect the two?

    you can do this by keeping the external hard drive connected and doing the following
    -hold shift key down on computer while opening iTunes and a prompt will appear to choose a library
    -select choose library, iTunes should bring up your explorer windows where you can search for the external HD
    -after you find the external HD find the iTunes folder you just copied to it
    -after opening the iTunes folder look for the file that says iTunes library.itl or if you can't see that extenstion just look for a document looking thing in the iTunes folder that shows up as a database file
    -double click the database file and boom iTunes should load your library without having to copy it to the computer
    PS: do make sure that if you are going to do it this way, make sure that the external HD is connected at all times, because if you don't then you will get exclamation marks next to your iTunes songs
    double PS: if you are unsure how to find out if the iTunes library file is a database file just right click it and choose properties and under the type it should say database file
    hope this helps:)

  • Hi, how can I limit the number of emails I can see on my iPhone 5. Every time in delete one and older email gets added from my live.co.uk account (where I want to keep my 2500 emails) I just don't want many on my phone. Thanks

    Hi, how can I limit the number of emails I can see on my iPhone 5. Every time in delete one and older email gets added from my live.co.uk account (where I want to keep my 2500 emails) I just don't want many on my phone. Thanks

    You can't. Why on earth would you attempt to manage 2500 emails with setting up a folder structure or some means of doing so? Simply keeping them in an single inbox is not realistic, no matter what email client you use.

  • How can I limit the number of messages coming into my email accounts on the IOS7

    I don't like the new IOS7 system most annoying is the excess battery useage and need to recharge the other is I can no longer limit the number of emails that are in my cell's email accounts old system let you choose the amount of messages. 
    already did the basic things to eliminate battery drainiage getting rid of open pages which was also annoying to figure out how to use as you can't simply click and hold then delete all open apps running in the back ground you must touch and slide them off the phone. I don't let apps do auto updates.
    They need to do something about the battery and having to have all emails on the phone which likely is sucking up space.
    Any suggestions?

    I don't think it matters what you use as your email client. This is a feature that existed before and was missed in the upgrade to IOS 7. I read on another post that if you contact Apple support they just tell you to report it in Apple feedback.  I just submitted feedback at http://www.apple.com/feedback/  I couldn't find an IOS section to post it to, so I just posted it in the iPhone section. Maybe if enough people do this, Apple will fix it.

  • When I air print from my iPad, I can't limit the number of pages. It just says print and the number of copies and I end up with way more than I want. How do I set it to limit the pages?

    When I air print using FingerPrint from my ipad, it doesn't let me limit the number of pages, and I end up with more pages than I want. It asks if I want multiple copies, but it doesn't ask me number of pages, or which pages. Is there a way to do this?

    When you use an AirPrint compatible printer, you get this option for page range. You are using your computer as the server in order to print, so you probably have to set the range on the computer. While you can print from your printer with this app, I assume that it doesn't give you the same control that you get directly from the iPad when using an AirPrint printer.
    Read this from the FingerPrint support site. Selecting the page range would be part of the formatting of a print job.
    http://fingerprint-support.collobos.com/knowledgebase/articles/66972-i-can-t-for mat-the-print-job

  • How do I limit the number of rows retrieved at a time using RefCursor?

    I have a PL/SQL package in use, that returns a REF CURSOR. This is currently being used in a Forms 6i application. Now I want to develop an ASP.NET web application that displays exactly the same information as my Forms 6i module. In fact those two applications will be used concurrently for a while.
    I looked at the sample code provided on otn.oracle.com and decided to use the OracleDataAdapter.Fill()-method to fill a dataset and bind that dataset to a pageable GridView. Now I wonder, whether this method retrieves ALL records of the query at once and how I can limit the number of rows fetched? The Select statement retrieves up to 10000 rows at a time. Most of the time, a user is only interested in the first 20-30 rows. Forms 6i fetches more rows as the user scrolls down, how can I implement the same behavior in ODP.NET?
    - Markus

    Excuse me, but the reply does not quite answer my question. Maybe I did not explain my concerns clear enough:
    I understand the use of the two properties (RowSize and FetchSize) to reduce the amount of round trips needed to transfer the data - not the number of rows fetched in total. This would still lead to a situation where all rows are transferred, when I am using the OracleDataAdapter.Fill()-Method. Is this correct or did I misunderstand the function of this method?
    I quote the otherwise really helpful article you send me:
    Of course, there is a cost if the fetch size is arbitrarily large. More client-side memory and processor cycles will be needed to store and manage a larger amount of data. The goal is to find a high-performing balance between the number of round trips and the amount of data retrieved per trip.
    My RowSize is for sure a bit larger than the one in the given example. The query will probably be used by up to 100 users at a time, so I would like to limit the resource-costs not only on the network by the number of round trips, but also on the web-server which is storing all these records in it's memory per user-request.

Maybe you are looking for

  • Help with changing to Sky TV

    Hi, I have just cancelled my BT Vision service (OH does not like it) but still have BT Broadband and Calls which we are not changing.  We have no phone line downstairs but a phone line upstairs and are using the BT powerline adapters.  The powerline

  • OnStatus returns wrong codes??

    I'm using the following code to record a stream on the server side,,,,,,the problem is onStatus only reports NetStatus.data.start and no other codes i don't even know what the code it does returns means as it is undocumented .....how can i make onSta

  • Install error: java.lang.NoClassDefFoundError: ScriptWrapper

    I got this error while doing an install of Grid Control 10.1.0.3 on Windows. Unlocking the repository passwords java.lang.NoClassDefFoundError: oracle/scriptwrapper/ScriptWrapper Exception in thread "main" Unlocking the repository password Failed Rep

  • [SOLVED]Kmail imcoming notification stopped working

    Hi! I have up-to-date system. My notification theme is colibri. Until few hours ago incoming notification worked but after i changed my plasma-theme to caledonia it stopped working. I doubt it that this is a reason because i changed the theme back to

  • Messing up when reconnect media

    Dear All, I always use reconnect media function, as we have 2-3 editors working at the same time on different machine and even locations. Everything goes well until connecting STP files. Now we are close to the end of the project and have been sendin