Changing a Single Threaded app into Multi Threaded app

Hi Java Experts
I made a web crawler that goes out to a particular web site and starts from there to crawl throughout the internet -- it's working fine . it only has 1 thread -- which is the main class which implements runnable.
I'm interested in making this solution multithreaded in hopes that I can get greater performance. -- since I believe the limiting factor is probably the speed at which URLs are returned etc --
MY QUESTION: how would you guys turn such a crawler into a multithreaded application.
my main class -- that does all the real work (with the help of some other classes works like this )
getTheNextURL(String urlString)
//step 1: check if it's a valid url
//step 2: check if it's a url we are interested in
//step 3: go to the url and gather all the links on that page put them in an array list
//step 4: loop through the array list
//call getTheNextURL(urlname) inside of the step loop
Does anyone see any way to make this multithreaded ? for increased urls looked at I was hoping i could possible multiply the url search speed by a factor of the threads.
Thanks in Advance for any suggestions that can be offered.
stev
i'm also aware of the problem with my recursive calls as read in the oriely java perfomance tuning book i'm looking to resolve thatas well with the most optimum algorithm

thanks for the suggestion sounds simple enough.
Since you made a great suggestion , what do you think about the recursion problem in my design.
Here's the problem
let's say the first web page it finds is a html page with the following links
link a
link b
link c
link d
It places these links in an ArrayList.
It loops through the ArrayList with an iterator and follows all the urls. starting with link a. On link a , the following link are found as seen below and placed in an ArrayList again.
link 1
link 2
link 3
link 4
then it will call the method again , which puts all the links found in an ArrayList and loops through it to follow the first.
This repeats over and over until it goes to the maximum depth specified , then it returns to the next iteration and looks through that. That's how it works in detail.
Every recursive call is an addition to the operating stack of the vm, so it's concievable that i may have 1000s of recursive calls stored on the stack each holding 1000s of ArrayList objects that it will consider.
I'm trying to figureout a better solution for this recursion to reduce the calls on the stack and implement multithreading at the same time.
Any ideas?
ps .
---- i would also like to be able to manually cancel threads that get caught in some infinite loop trick web pages out there.

Similar Messages

  • Transfer single edition app to another developer

    Hi,
    Can I change the single edition app developer to another developer after the publishing in App Store?
    In iTunes connect developer guide is written:
    -Make sure the app uses only technology and content that can be transferred.
    -No version of the app can use an iCloud entitlement.
    -No version of the app can use a Passbook entitlement.
    - The app can’t offer (or have previously offered) In-App Purchase subscriptions: auto-renewable, free, or non-renewing.
    In-app purchase in Single Edition is automatically enabled when I create App ID (with DPS Guide), but, as a Single Edition, it can’t have any In-App Purchase subscription.
    Do you think this could be a problem in order to change the App Developer once it’s published in App Store?

    Apple responded:
    In-App Purchase subscriptions are a types of In-App Purchases. Your app may contain In-App Purchases other than auto-renewable, free, or non-renewing when transferring an app. Please be advised that if your app offered subscription In-App Purchases you will be unable to use the App Transfer process.
    this is my app in appstore (don't have "in-App purchase icons)

  • How should implement multi-thread in single-threaded Operating system using

    How should implement multi-thread in single-threaded Operating system using java?
    Java supports "Multi-threading".Is there is any way run the multiple threads (Implementing multi threading) using java in a Single-threaded Operating system (That is the operating system does not support for multi-threading).

    Previous questions from OP suggest they are using J2ME, so the question might be possible.
    806437 wrote:
    How should implement multi-thread in single-threaded Operating system using java?
    What is the actual question/problem?
    A java app doesn't do threads or not do threads. It uses classes. The VM does threads.
    So if you have a platform that does not have threads and you want to support the thread class then the VM, not a java app, must provide some pseudo mechanism, such as green threads, to support that.
    If your question is about java code and not the VM then you must build a task engine and insure that the tasks are of short enough duration that it is an effective use for your system.

  • How to migrate single folio app into multi folio app when each were created w/ different adobe id

    I have a single folio app in iTunes that was created using adobe ID "A". I also have a multi folio app in iTunes that was created using adboe ID "B".  How do I migrate the single folio app into the new multi folio app, ensuring that apple sees it as an update so users of the single folio app are notified of an update. Both apps were published using the same apple distribution id. Step-by-step help would be greately appreciated.

    In your case, I would create a multi-folio version of the app and then use iTunes Connect to submit it as an update to the previous version of the app. When users update the app, they'll lose the folio that was previously baked into the app, but they can download that folio—and others—from the library of the new version. You'll want to make those folios available in Adobe ID 'B', which should be the Title ID you use when you build the app. I think all you need to do for your existing customers is describe the change to the app in the update description in iTunes Connect.

  • Is rendering in Final Cut single thread or multi thread?

    There seems to be this recurring message about how the new Macpros perform single-threaded tasks about the same as the previous gen of Macpros, however in multi-threaded tasks the new Pros shine.
    How do I know if a task is single-threaded or multi-threaded? I do a lot of rendering video filters, generators, effects, etc. in Final Cut. Even something as (seemingly) simple as generating scrolling credits takes forever to render.
    Is video rendering a multi-threaded task? Will I see time significant time savings in rendering with the new Pro machines?

    It's not right now but the new Mac Pros are faster in single-threaded modes anyway:
    http://www.macrumors.com/2009/03/14/updated-mac-pro-benchmarks-and-video-of-inte rnals/
    Turns out the initial benchmarks were incorrect. The integrated memory controller is a MASSIVE performance boost. But it is inevitable that Apple will eventually choose the multi-threaded route for Final Cut Studio anyway, even if they do not at the present.

  • HttpService + Asynchronous + Single thread

    I have a internal company Flex app similar to Jmeter. It generates HTTP requests and outputs based on asserts. The app uses Puremvc and leverages notifications to bring event-based asynchronous model. On a full-blown scan, I have two challenges:
    1. To throttle requests so that the view is quick to appear (initially). A full blown scan generates 1040 requests, and the view doesn't appear for a few secs till all the requests are queued. Is there a way, I can force the view to come quickly before I complete the pushing of requests.  I have implemented a throttle approach, but the results are not any better than no throttling.
    2. I am forced to set httpservice.requestTimeout to 300 secs, as what I have found is that the thread eventually forces the timeout as due the single threading model, Flex hasn't been able to send the request through before a normal timeout of 15 secs is completed.
    3. Is there a way to open more persistent connections to leverage, so that the performance of such bursts are improved?
    Don't expect a reply, but any thoughts are welcome.....

    Here is an ActionScript library that supposedly allows you to come closer to multi-threading:
    http://code.google.com/p/async-threading/downloads/list
    If you just want the UI to appear, have or generate minimal sample data, to be replaced as the data comes in. That way the UI can come up with reasonable minimum data for the UI.
    Can the requests either be chunked into small pieces to facilitate quicker completion of requests, or else larger chunks to reduce the overall number of requests.
    Can you compress the data and decompress after receipt to reduce the transfer load?
    With your volume of requests it boils down to experimentation and consideration and what gives the best performance. I've never dealt with such issues, but thought I would share my ideas.

  • RE: DBSessions and Single-threading

    Thanks Linh. Always good to here from you.
    thanks
    ka
    Kamran Amin
    Forte Technical Leader, Core Systems
    (203)-459-7362 or 8-204-7362 - Trumbull
    [email protected]
    From: Linh Pham[SMTP:[email protected]]
    Sent: Friday, November 13, 1998 2:51 PM
    To: Ajith Kallambella M; [email protected]; ForteUsers;
    [email protected]
    Subject: RE: DBSessions and Single-threading
    all,
    This information (technote draft # 11716) is to clear up the confusion
    regarding
    database access.
    Note, Forte reserves the right to change this implementation in the
    future.
    Currently, there are two flavors of database access available with forte
    (as of version 30j1):
    1. single-threading access to all databases on all UNIX & VMS platforms
    2. multithreading access to all supported database except Sybase on
    intel/alpha-NT,
    and to a certain extent, limited support with SQLServer (see more
    details below)
    1. single-threading access:
    with this type of access, when the following code is executed
    (SQL select ... on MyDBSession;), forte locks the partition and
    all EXTERNAL requests will be queued. However, task switching inside
    the partition continues until the called task enters the DBVendor's
    API (as with any 3GL call). Prior to this moment, you can still have
    multiple tasks running inside the partition. As the called task
    enters the 3GL, it truly blocks a partition, ie. it's OUT there
    talking to the database and not communicating with the
    the forte's environment. If the query is long, the partition might not
    be
    able to acknowledge the environment manager's ping, and thus, will be
    deemed NOT reachable, and a new partition will be started (see technote
    11147). Another problem arises when you have multiple INTERNAL tasks
    trying to perform database access concurrently on the same DBSession.
    Since the behavior is unpredictable, we RECOMMEND that you only
    have ONE task at any time accessing the DBSession inside a partition.
    Please see also technote 7104 for more information regarding DBSession
    sharing & blocking.
    2. multi-threading access:
    on NT, we have added code to allow multithreading access to most
    supported
    database. What does this mean?
    a. when a task access the database, the partition will NOT be blocked.
    b. you can have multiple DBSessions inside a partition and allow
    concurrent access; however, we still RECOMMEND that you
    only have ONE task accessing a DBSession at any one time.
    Please consult a Forte consultant or a TSR in reference to technote
    11151 (only available internally). Please do NOT call Forte Technical
    Support for this technote.
    As to SQLServer, the ODBC driver that you use to access the database
    will
    determine if it's is reentrant or not. There is also a known problem
    with
    the Microsoft ODBC driver which causes the cursor state to become
    invalid when
    multiple tasks accessing the same session. Due to these problems, forte
    recommends that you single-threading access to SQLServer; otherwise
    use at YOUR OWN RISK.
    Hope this helps. IF you have questions regarding multithreading access
    support
    in the future, please contact a Forte Sales Rep or TSR.
    linh ...
    -----Original Message-----
    From: [email protected]
    [<a href="mailto:[email protected]">mailto:[email protected]]On</a> Behalf Of Ajith Kallambella M
    Sent: Friday, November 13, 1998 9:08 AM
    To: [email protected]; ForteUsers; [email protected]
    Subject: RE: DBSessions and Single-threading
    Though, the DBSession partitions can reside on a
    thread-safe
    OS ( like NT ), the DBSession is still single threaded
    and your
    partition gets blocked for the duration of the DB
    access. Same
    is true, even if you have multi-threaded databases.
    Forte has not changed DBSession to make it
    multi-threaded.
    Infact, given the current implementation, the only way
    to simulate
    concurrent database access is to replicate the
    partition which
    has DBSession object. The famous DBEntityManagerPattern
    does essentially the same.
    I think we should all feel happy with this now, and
    hope for
    something better in 4.0.
    Ajith Kallambella. M
    Forte Systems Engineer,
    International Business Corporation
    -----Original Message-----
    From: Eric Pereira [<a href=
    "mailto:[email protected]">mailto:[email protected]</a>]
    Sent: Friday, November 13, 1998 9:54 AM
    To: [email protected]
    Cc: [email protected]
    Subject: RE: DBSessions and Single-threading
    Kamran,
    That's not entirely correct. Partitions which access
    multi-threaded
    databases (like MS SQL Server on NT) do not block.
    There was some
    discussion about this over the User Group a while back
    - with no real
    conclusion, so perhaps Forte might want to step in and
    clarify.
    What I'm curious about is the outcome in a situation
    where one DB
    Session accesses SQL Server and another one talks to a
    non
    multi-threaded database within the same partition.
    Thanks.
    Eric Pereira
    Forte Consultant
    ----Original Message Follows----
    From: "Amin, Kamran" <[email protected]>
    To: [email protected], Peter Kelly
    <[email protected]>
    Subject: RE: DBSessions and Single-threading
    Date: Fri, 13 Nov 1998 07:52:09 -0500
    Reply-To: "Amin, Kamran" <[email protected]>
    Peter,
    If one of the service object is being used the that
    partition gets
    blocked until it has finished the request to the
    dbsession. It will not
    mater if the service objects are connected to different
    database. Using
    a
    dbsession makes the partition single threaded and
    that's why we use load
    balancing. Please look at tech. note 10647 for more
    info.
    ka
    Kamran Amin
    Forte Technical Leader, Core Systems
    (203)-459-7362 or 8-204-7362 - Trumbull
    [email protected]
    From: Peter Kelly[SMTP:[email protected]]
    Sent: Friday, November 13, 1998 6:27 AM
    To: [email protected]
    Subject: DBSessions and Single-threading
    Does a DBSession executing in a partition cause thatpartition to
    become
    single-threaded?
    Suppose a partition has 2 Service Objects.
    Each Service Object has its own unique DBSession.
    While a method in one Service Object is using itsDBSession,
    do all other threads in that partition halt and thenresume
    when the work with the first DBSession is complete.
    What if the two DBSessions are connected to differentdatabases,
    does this change anything?
    I heard rumours that Oracle on NT supportedmulti-tasking and blocking
    would not occur. If blocking does occur, is it aForte or Oracle
    limitation?
    Any input/comments appreciated.
    thanks,
    Peter
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive
    <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>
    >>
    >>
    Get Your Private, Free Email at <a href=
    "http://www.hotmail.com">http://www.hotmail.com</a>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive
    <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>
    >>
    >>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>
    >>
    >
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>

    Thanks Linh. Always good to here from you.
    thanks
    ka
    Kamran Amin
    Forte Technical Leader, Core Systems
    (203)-459-7362 or 8-204-7362 - Trumbull
    [email protected]
    From: Linh Pham[SMTP:[email protected]]
    Sent: Friday, November 13, 1998 2:51 PM
    To: Ajith Kallambella M; [email protected]; ForteUsers;
    [email protected]
    Subject: RE: DBSessions and Single-threading
    all,
    This information (technote draft # 11716) is to clear up the confusion
    regarding
    database access.
    Note, Forte reserves the right to change this implementation in the
    future.
    Currently, there are two flavors of database access available with forte
    (as of version 30j1):
    1. single-threading access to all databases on all UNIX & VMS platforms
    2. multithreading access to all supported database except Sybase on
    intel/alpha-NT,
    and to a certain extent, limited support with SQLServer (see more
    details below)
    1. single-threading access:
    with this type of access, when the following code is executed
    (SQL select ... on MyDBSession;), forte locks the partition and
    all EXTERNAL requests will be queued. However, task switching inside
    the partition continues until the called task enters the DBVendor's
    API (as with any 3GL call). Prior to this moment, you can still have
    multiple tasks running inside the partition. As the called task
    enters the 3GL, it truly blocks a partition, ie. it's OUT there
    talking to the database and not communicating with the
    the forte's environment. If the query is long, the partition might not
    be
    able to acknowledge the environment manager's ping, and thus, will be
    deemed NOT reachable, and a new partition will be started (see technote
    11147). Another problem arises when you have multiple INTERNAL tasks
    trying to perform database access concurrently on the same DBSession.
    Since the behavior is unpredictable, we RECOMMEND that you only
    have ONE task at any time accessing the DBSession inside a partition.
    Please see also technote 7104 for more information regarding DBSession
    sharing & blocking.
    2. multi-threading access:
    on NT, we have added code to allow multithreading access to most
    supported
    database. What does this mean?
    a. when a task access the database, the partition will NOT be blocked.
    b. you can have multiple DBSessions inside a partition and allow
    concurrent access; however, we still RECOMMEND that you
    only have ONE task accessing a DBSession at any one time.
    Please consult a Forte consultant or a TSR in reference to technote
    11151 (only available internally). Please do NOT call Forte Technical
    Support for this technote.
    As to SQLServer, the ODBC driver that you use to access the database
    will
    determine if it's is reentrant or not. There is also a known problem
    with
    the Microsoft ODBC driver which causes the cursor state to become
    invalid when
    multiple tasks accessing the same session. Due to these problems, forte
    recommends that you single-threading access to SQLServer; otherwise
    use at YOUR OWN RISK.
    Hope this helps. IF you have questions regarding multithreading access
    support
    in the future, please contact a Forte Sales Rep or TSR.
    linh ...
    -----Original Message-----
    From: [email protected]
    [<a href="mailto:[email protected]">mailto:[email protected]]On</a> Behalf Of Ajith Kallambella M
    Sent: Friday, November 13, 1998 9:08 AM
    To: [email protected]; ForteUsers; [email protected]
    Subject: RE: DBSessions and Single-threading
    Though, the DBSession partitions can reside on a
    thread-safe
    OS ( like NT ), the DBSession is still single threaded
    and your
    partition gets blocked for the duration of the DB
    access. Same
    is true, even if you have multi-threaded databases.
    Forte has not changed DBSession to make it
    multi-threaded.
    Infact, given the current implementation, the only way
    to simulate
    concurrent database access is to replicate the
    partition which
    has DBSession object. The famous DBEntityManagerPattern
    does essentially the same.
    I think we should all feel happy with this now, and
    hope for
    something better in 4.0.
    Ajith Kallambella. M
    Forte Systems Engineer,
    International Business Corporation
    -----Original Message-----
    From: Eric Pereira [<a href=
    "mailto:[email protected]">mailto:[email protected]</a>]
    Sent: Friday, November 13, 1998 9:54 AM
    To: [email protected]
    Cc: [email protected]
    Subject: RE: DBSessions and Single-threading
    Kamran,
    That's not entirely correct. Partitions which access
    multi-threaded
    databases (like MS SQL Server on NT) do not block.
    There was some
    discussion about this over the User Group a while back
    - with no real
    conclusion, so perhaps Forte might want to step in and
    clarify.
    What I'm curious about is the outcome in a situation
    where one DB
    Session accesses SQL Server and another one talks to a
    non
    multi-threaded database within the same partition.
    Thanks.
    Eric Pereira
    Forte Consultant
    ----Original Message Follows----
    From: "Amin, Kamran" <[email protected]>
    To: [email protected], Peter Kelly
    <[email protected]>
    Subject: RE: DBSessions and Single-threading
    Date: Fri, 13 Nov 1998 07:52:09 -0500
    Reply-To: "Amin, Kamran" <[email protected]>
    Peter,
    If one of the service object is being used the that
    partition gets
    blocked until it has finished the request to the
    dbsession. It will not
    mater if the service objects are connected to different
    database. Using
    a
    dbsession makes the partition single threaded and
    that's why we use load
    balancing. Please look at tech. note 10647 for more
    info.
    ka
    Kamran Amin
    Forte Technical Leader, Core Systems
    (203)-459-7362 or 8-204-7362 - Trumbull
    [email protected]
    From: Peter Kelly[SMTP:[email protected]]
    Sent: Friday, November 13, 1998 6:27 AM
    To: [email protected]
    Subject: DBSessions and Single-threading
    Does a DBSession executing in a partition cause thatpartition to
    become
    single-threaded?
    Suppose a partition has 2 Service Objects.
    Each Service Object has its own unique DBSession.
    While a method in one Service Object is using itsDBSession,
    do all other threads in that partition halt and thenresume
    when the work with the first DBSession is complete.
    What if the two DBSessions are connected to differentdatabases,
    does this change anything?
    I heard rumours that Oracle on NT supportedmulti-tasking and blocking
    would not occur. If blocking does occur, is it aForte or Oracle
    limitation?
    Any input/comments appreciated.
    thanks,
    Peter
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive
    <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>
    >>
    >>
    Get Your Private, Free Email at <a href=
    "http://www.hotmail.com">http://www.hotmail.com</a>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive
    <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>
    >>
    >>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>
    >>
    >
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>

  • I have a doubt about The Single-Thread Rule

    The [url http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html#rule]Single Thread Rule states:
    Rule: Once a Swing component has been realized, all code that might affect or depend on the state of that component should be executed in the event-dispatching thread.
    I began to wonder about this because so much code seems to work just fine when it isn't executed in the event dispatching thread. Why are there exceptions? I went looking for some code which acted differently when executed on the event thread than when it was not. I found this
    http://forum.java.sun.com/thread.jsp?forum=57&thread=410423&message=1803725#1803725
    Now I started wondering why this was the case. What I found was that DefaultCaret adds a document listener to the document of the JTextComponent. In this listener, the insertUpdate() method specifically tests if it is running on the event dispatch thread and if it is, it updates the caret position.public void insertUpdate(DocumentEvent e) {
        if (async || SwingUtilities.isEventDispatchThread()) {
            // ... update the caret position ...
    }I then copied the code from DefaultCaret and made a MyCaret. I needed to tweek the code a little bit, but it ran. I removed the event thread test. It worked outside the event thread. There was a small difference in the results though. The textarea did not scroll all the way to the bottom. Almost, but not quite. I didn't test enough to make sure this was the only problem, but there was at least one problem.
    Now I started think about why this would be. The thought crossed my mind that the order of the events which were posted to the event queue were probably important. Sun found bugs when components were updated out of the event thread, so they essentially ignored events which weren't on the event thread and created the The Single-Thread Rule.
    A few days pass. I'm starting to wonder if Sun could have done a better job making Swing components thread safe. I also don't know that this specific case I found was the rule or the exception to the rule. But without insight into the design philosopy of Swing, I would have to examine all their components and see how they have written them and see if I can come up with a better design. That sound like a lot of work. Especially without getting paid for it.
    But wait a second, all you have to do is call the append() method of JTextArea on the event thread. If that is the case, why didn't they write the freakin component that way? Well, I'll try itclass MyTextArea extends JTextArea {
      public MyTextArea(int rows, int columns) { super(rows,columns); }
      public void append(final String text) {
        if (SwingUtilities.isEventDispatchThread()) super.append(text);
        else {
          SwingUtilities.invokeLater(new Runnable() {
            public void run() { myAppend(text); }
      private void myAppend(String text) { super.append(text); }
    }I change [url http://forum.java.sun.com/thread.jsp?forum=57&thread=410423&message=1803725#1803725]camickr's code to use a MyTextArea and it works fine without calling from the event thread. I've essentially moved The Single-Thread Rule to the component itself rather than relying on each and every one of the [url http://www.aboutlegacycoding.com/default.htm?AURL=%2FSurveys%2FSurvey6intro%2Easp]2.5 million Java programmers worldwide to use SwingUtilities.invaokeLater().
    Now for my question...
    Why didn't Sun do this?

    Swing is slow enough as it is. Lets not make it slower
    just
    because dense "programmers" don't know what they are
    doing.I agree with you in defending the current model, but aren't you a bit harsh there?!? ;-)
    Well, there are a number of not-so-dense programmers that expect such high-level components to be thread-safe. The question is worth asking whether Sun intentionally favor the explicit thread management for performance reasons, or whether this was an oversight.
    I'd go for the former (intentional) : indeed any GUI toolkit is inherently thread-based; there is always a distinction between the graphical thread(s) and the application threads - and the programmer always has to manage explicit thread creation to handle long-running event handlers without blocking the event dispatching thread. Extending thread concerns to the updating of components is therefore not a big move.
    So it seems fair that a core GUI toolkit does not hide thread issues (though to the best of my knowledge there is no such limitation in updating AWT components), or at least that's what Sun deemed.
    An ease-of-use-focused toolkit wrapping the core toolkit for thread-safety can be provided as a third-party product. Though I agree that wrapping the dozens of existing widgets and hundreds of methods is cumbersome - and the lack of such products probably shows it would have a low added value to trained developpers.
    Because your way is an extra method call and if
    statement, neither of which is necessary if you already know you
    are in the correct thread. Now count the number of methods
    which will need to be changed (and add up the extra cost).Indeed it's quite common to update several properties of several widgets in one bulk (when user clicks "OK", add a row to the table, change the title of the window, update status bar, re-enable all buttons, change some color,...).
    In this case explicit thread management doesn't spare one if but a dozen of redundant ifs!
    Note that there could have been if-less ways to cope for thread safety, such as creating a copy of the component's model when a change is made to a component, and switching the model only before paint() is called in the event-dispatching - of course coalescing all changes into the same "updated" model until paint() is called.
    But this would trade ease of use for redundant memory consumption, especially for some components with potentially huge models (JTree, JTable, JTextArea,...). And Swing appears to be already quite memory-greedy!

  • Help! My application uses a Single Thread !

    Hi all !
    I have a web application which performs some long running tasks. This can be easily simulated with:
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              System.out.println("Started Long Running Task!");
              try {
                   Thread.sleep(20000);
              } catch (InterruptedException e) {
                   e.printStackTrace();
              System.out.println("Done");
    In order to deal with Long Running Tasks, I have created a WorkManager with MinThreads 10 and MaxThreads 100
    Then I have assigned the Work Manager to the Web application usign weblogic.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90">
    <wl-dispatch-policy>WorkManager-0</wl-dispatch-policy>
    </weblogic-web-app>
    However it seems that the Web application uses a SINGLE Thread to reply to the Servlet. In other words issuing n parallel requests the output is:
    Started Long Running Task!
    [20 Seconds Pause]
    Started Long Running Task!
    [20 Seconds Pause]
    Started Long Running Task!
    [20 Seconds Pause]
    Started Long Running Task!
    [20 Seconds Pause]
    My settings are the default Weblogic 12c Server settings, I've just added Weblogic NIO performance libs to the Java's path.
    Is there any setting which allow just 1 Socket for my application ? Maybe it's because I'm using the "unlicensed" (free download) server version ?
    Thanks a lot
    Frank

    You need to create separate Windows user accounts if you want to seperate the behaviour of iTunes for each user. That also means separate iTunes libraries for each user.
    Windows is a multi-user operating system but you are not using it properly. iTunes is not a multi-user application. No application is. You can't expect it to treat different users differently when they are all using the same computer user account.
    Do you understand what I mean?

  • Single threading

    Hi All,
    After porting the application from sun v440 server to T5120 sun sparc server, the application performance degraded.
    Due to some application issues, decided to run the JDE application in single thread mode. Not yet started.
    But my question is even if we run the application in single thread mode, the server architecture is CMT (Chip Multi Threading) with 8 core cpu (cpu-count=32) which works best if
    parallelism and concurrency is at peak, will it improve the performance.
    What should be a optimal solution of running a single threaded application in CMT servers.
    Can the JDE applications be running in single thread mode performs better in CMT servers?
    Edited by: Verma on Nov 2, 2010 11:18 AM

    It might be best to ask about this on the Integration forum. I'm not certain which one it is, but browse through [http://forums.oracle.com/forums/main.jspa?categoryID=84] to find it.
    However, my spin on this would be: Restricting a JPD to a single thread would require changing the attributes of the underlying stateless session bean to have a "max-beans-in-thread-pool" value of 1. I don't know if the current WLI allows any direct control over this. It's conceivable a custom build step using XSLT could modify the ejb-jar.xml file to set this attribute this way (I've done exactly this modification in the WLI 8.1 timeframe).

  • Change 5977383300318 for thread 2 is in sequence #4

    Hi All,
    the database was a single one on 10gR2
    i was doing a cold clone from one instance to another, when running recover
    "recover database using backup controlfile"
    it was always looking for sequence # 4 but in the archive log i only have #2 and #3.
    i do not have sequence #4 anywhere on the system.
    can you suggest a solution for this?
    Thanks in advance.
    SQL*Plus: SYS@CLONE >recover database using backup controlfile;
    ORA-00279: change 5977383300318 generated at 05/05/2010 11:59:06 needed for
    thread 2
    ORA-00289: suggestion : /u10/app/oracle/oradata/arch/2_4_718195767.arc
    ORA-00280: change 5977383300318 for thread 2 is in sequence #4
    Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
    /u10/app/oracle/oradata/arch/2_3_718195767.arc
    ORA-00310: archived log contains sequence 3; sequence 4 required
    ORA-00334: archived log: '/u10/app/oracle/oradata/arch/2_3_718195767.arc'

    Hello,
    When you Backup the database you should either:
    1. Make a Cold Backup:
    - Shutdown the original database and copy it's datafiles, redolog files, controlfiles, PFILE/SPFILE.
    2. Make a Hot Backup:
    - Set the original database in BEGIN BACKUP mode, then copy the datafiles, controlfiles, PFILE/SPFILE.
    - Generate a last Archive log alter system switch logfile; and copy all the Archived log since the beginning of the Backup.
    - Set the original database in END BACKUP mode.
    In the first case, you don't need to make a Recovery.
    In the second case you'll have to make a Recovery.
    Else, you may use the DUPLICATE statement from RMAN:
    http://download.oracle.com/docs/cd/B19306_01/backup.102/b14191/rcmdupdb.htm
    Hope this help.
    Best regards,
    Jean-Valentin

  • Waiting for a mouse click in a single thread

    Here's my problem:
    I'm working on a program I didn't initially create, and I picked it up from the rough midpoint of its evolution. It is a single thread AWT program, with a mouseListener interface already implemented.
    Here's my problem. In a game setting, we have two players. It is no problem when both are computer controlled. When player one is controlled by a human, I need to wait for a mouse event before returning, because upon returning player two moves (regardless of its player configuration).
    I can't do any kind of busy waiting because it is a single thread. I'm looking for some kind of option besides making the program multithreaded. This also makes it difficult to use some sort of boolean variable, though I don't think it's impossible.
    Thanks in advance for any help.
    Eric

    #9 - You are correct in your assumptions. I agree it's
    not the best model, but it worked for the original
    purpose, which was to have one player always
    controlled by the computer, and the option of
    selecting a second player as being either human or
    computer. Since each move is made manually - that is,
    for a move to be made, it requires user input - there
    was no harm in returning from a function, because it
    had no immediate computation. The requirements have
    just changed, and now I must allow both players to be
    selectable. This presents a problem in that I have to
    wait for the move actions to finish before
    proceeding.Understood.
    >
    My only question is, how can I access the AWT thread?You mentioned in an earlier post that you have action listeners. As triggered by user events, these are always called on the AWT thread. For example:
    import javax.swing.*;
    import javax.awt.event.*;
    JButton button = new JButton( new AbstractAction {
            public void actionPerformed(ActionEvent e) {
                synchronized (myMonitor) {
                    myMonitor.notifyAll();
        });This button can be added to some swing UI. If clicked on, then actionPerformed will be called on the AWT thread, and any threads waiting on myMonitor will be notified.
    I see what you are saying - it's almost exactly what
    my coworkers told me - but I don't have the knowledge
    to implement it, which is why I'm here. Creating a
    monitor object isn't a problem (makeMove() would need
    to be synchronized, otherwise you wouldn't be able to
    call wait()),I recommend using a separate object for the monitor, especially if you are already using synchronized, so that you know exactly how each object's lock is being used. If you're sure it is safe, then there is nothing wrong with using the object itself as the monitor, as you suggest, however.
    but I'm not sure what you mean by the
    action handling method should be called on the AWT
    thread.Just that any action listener method is always called on the AWT thread in response to user action.
    Dave

  • Thread: Could not generate the XML in single thread mode

    Hi all,
    I have created a report using PLSQL Procedure method after submitting the request I am getting the following Error.Couldn't sort out why I am getting the error while running the report.
    Error in "Multi threaded or single threaded execution block" of XXRX_REPORT_OUTPUT_PKG.insert_into_nested_table procedure
    ERROR :ORA-20005: Could not generate the XML in single thread mode
    XXRXERROR: XXRX_REPORT_OUTPUT_PKG.run_report SQLERROR: ORA-20005: ORA-20005: Could not generate the XML in single thread mode
    Can someone help me out finding the issue
    Thanks in Advance

    Hi,
    Please read SQL and PL/SQL FAQ
    We cannot guess what is the error if you don't post any part of your code.
    Additionally when you put some code or output please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • DBMS_PARALLEL_EXECUTE multiple threads taking more time than single thread

    I am trying to insert 10 million records from source table to target table.
    Number of chunks = 100
    There are two scenarios:
    dbms_parallel_execute(..... parallel_level => 1) -- for single thread
    dbms_parallel_execute(..... parallel_level => 10) -- for 10 threads
    I observe that the average time taken by 10 threads to process each chunk is 10 times the average time taken in case of single thread.
    Ideally it should be same which would reduce the time taken by a factor of 10 (due to 10 threads).
    Due to the above mentioned behavior, the time taken is the same in both cases.
    It would be great if anybody can explain me the reason behind such behavior.
    Thanks in advance

    Source Table = TEST_SOURCE
    Target Table = TEST_TARGET
    Both tables have 100 columns
    Below is the code:
    DECLARE
    l_task VARCHAR2(30) := 'test_task_F';
    l_sql_stmt VARCHAR2(32767);
    l_try NUMBER;
    l_stmt VARCHAR2(32767);
    l_status NUMBER;
    BEGIN
    l_stmt := 'select dbms_rowid.rowid_create( 1, data_object_id, lo_fno, lo_block, 0 ) min_rid,
                                       dbms_rowid.rowid_create( 1, data_object_id, hi_fno, hi_block, 10000 ) max_rid
                                       from (
                                       select distinct grp,
                                  first_value(relative_fno)
                                  over (partition by grp order by relative_fno, block_id
                                  rows between unbounded preceding and unbounded following) lo_fno,
                                  first_value(block_id )
                                  over (partition by grp order by relative_fno, block_id
                                  rows between unbounded preceding and unbounded following) lo_block,
                                  last_value(relative_fno)
                                  over (partition by grp order by relative_fno, block_id
                                  rows between unbounded preceding and unbounded following) hi_fno,
                                  last_value(block_id+blocks-1)
                                  over (partition by grp order by relative_fno, block_id
                                  rows between unbounded preceding and unbounded following) hi_block,
                                  sum(blocks) over (partition by grp) sum_blocks
                                  from (
                                  select relative_fno,
                                  block_id,
                                  blocks,
                                  trunc( (sum(blocks) over (order by relative_fno, block_id)-0.01) / (sum(blocks) over ()/100) ) grp
                                  from dba_extents
                                  where segment_name = upper(''TEST_REGION_SOURCE'')
                                  and owner = ''FUSION'' order by block_id
                             (select data_object_id from user_objects where object_name = upper(''TEST_REGION_SOURCE'') )';
    DBMS_PARALLEL_EXECUTE.create_task (task_name => l_task);
    DBMS_PARALLEL_EXECUTE.create_chunks_by_sql(task_name => l_task,
    sql_stmt => l_stmt,
    by_rowid => true);
    l_sql_stmt := 'insert into FUSION.TEST_REGION_TARGET(REGION_ID,REGION1,REGION2,REGION3,REGION4,
                             ...., REGION99
                             SELECT REGION_ID,REGION1,REGION2,REGION3,REGION4,
                             .....,REGION99
                             from FUSION.TEST_REGION_SOURCE WHERE (1=1) AND rowid BETWEEN :start_id AND :end_id ';
    DBMS_PARALLEL_EXECUTE.run_task(task_name => l_task,
    sql_stmt => l_sql_stmt,
    language_flag => DBMS_SQL.NATIVE,
    parallel_level => 10);
    -- If there is error, RESUME it for at most 2 times.
    l_try := 0;
    l_status := DBMS_PARALLEL_EXECUTE.task_status(l_task);
    WHILE(l_try < 2 and l_status != DBMS_PARALLEL_EXECUTE.FINISHED)
    Loop
    l_try := l_try + 1;
    DBMS_PARALLEL_EXECUTE.resume_task(l_task);
    l_status := DBMS_PARALLEL_EXECUTE.task_status(l_task);
    END LOOP;
    DBMS_PARALLEL_EXECUTE.drop_task(l_task);
    END;
    Edited by: 943978 on Jul 2, 2012 9:22 AM

  • How to improve spreadsheet speed when single-threaded VBA is the bottleneck.

    My brother works with massive Excel spreadsheets and needs to speed them up. Gigabytes in size and often with a million rows and many sheets within the workbook. He's already refined the sheets to take advantage of Excel's multi-thread recalculation and
    seen significant improvements, but he's hit a stumbling block. He uses extensive VBA code to aid clarity, but the VB engine is single-threaded, and these relatively simple functions can be called millions of times. Some functions are trivial (e.g. conversion
    functions) and just for clarity and easily unwound (at the expense of clarity), some could be unwound but that would make the spreadsheets much more complex, and others could not be unwound. 
    He's aware of http://www.analystcave.com/excel-vba-multithreading-tool/ and similar tools but they don't help as the granularity is insufficiently fine. 
    So what can he do? A search shows requests for multi-threaded VBA going back over a decade.
    qts

    Hi,
    >> The VB engine is single-threaded, and these relatively simple functions can be called millions of times.
    The Office Object Model is
    Single-Threaded Apartments, if the performance bottleneck is the Excel Object Model operation, the multiple-thread will not improve the performance significantly.
    >> How to improve spreadsheet speed when single-threaded VBA is the bottleneck.
    The performance optimization should be based on the business. Since I’m not familiar with your business, so I can only give you some general suggestions from the technical perspective. According to your description, the size of the spreadsheet had reached
    Gigabytes and data volume is about 1 million rows. If so, I will suggest you storing the data to SQL Server and then use the analysis tools (e.g. Power Pivot).
    Create a memory-efficient Data Model using Excel 2013
    and the Power Pivot add-in
    As
    ryguy72 suggested, you can also leverage some other third party data processing tool
    according to your business requirement.
    Regards,
    Jeffrey
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for