Cross Thread Interaction

Hi to everyone,
I am a C# developer and I am making the move to Java and I have something I'd like to ask about Java Threads.
I have a Main class that starts 3 Threads. The first scans an external drive recursively, the second opens and reads in some details from some very large log files (in excess of 150mb's), and the third deals with the GUI.
I have these 3 items as threads because I want the application to appear as responsive as possible without the screen freeze that happens without them. (the GUI might not have to stay in a thread but it is for now).
My question is, how can I get the directory scanning thread and the log file reader thread to put the data they gather into textAreas that are on the GUI thread?
In C#, Microsoft's idea is that only the Thread that created a control should be able to interact with it (although this can be changed by setting CheckForIllegalCrossThreadCalls to false) and while this is obviously for safety it is often awkwardly restrictive.
So how do I go about this in Java?
I could do this ever-so simply in C# but it has been requested that this be done in Java, and I am in agreement as running on Linux is a must (Mono has been ruled out.) and I rather like Java.
Any advice would be greatfully appreciated.

If you are using java 5 or 6, did you consider package [java.util.concurrent|http://java.sun.com/javase/6/docs/api/java/util/concurrent/package-summary.html|javadoc]? - "Utility classes commonly useful in concurrent programming."

Similar Messages

  • B1 8.8 EventLogger:  Cross-thread operation not valid

    Greetings,
    I'm  trying to run EventLogger on Windows Server 2008 for use with B1 8.8.  I converted EL to VS 2005, updated it to use the new UI for 8.8 and when EL runs it crashes as soon as it receives an event.
    The message is "Cross-thread operation not valid: Control 'ToolBar1' accessed from a thread other than the thread it was created on.
    Does anyone have any ideas?  I wouldn't be surprised if it's a security issue, but I wouldn't know how to fix it even if it were.
    Thanks!

    Sheer Genius, Eddy - thanks!
    I tried recompiling the program and used the advanced compile option to tell it X86 but that didn't solve it (by itself, anyway) but when I used the compability mode everything was smooth.

  • Thread Interaction

    I am writing a server - client program to transfer some data. First the main listens for a socket connection (main thread)
    while (listening) new ServerComm(serverSocket.accept()).start();The class ServerComm(socket) is the second thread, it also implements an interface called PacketReader:
    public interface PacketReader {
         public void processPacket(CommPacket packet);
    public class ServerComm extends Thread implements PacketReader {
        private Socket socket = null;
        private CommTxRx comm = null;
        private boolean ack = false;
        private int status = 0x00;
        public ServerComm(Socket socket) {
          super("ServerComm");
          this.socket = socket;
        public void run() {
            comm = new CommTxRx(socket,this); comm.start();
            synchronized (this) {
                 while (status != DONE || status != ABORT) {
                      try { wait(400);
                        } catch (InterruptedException e) { status = ABORT; }
              comm.close();
         public void processPacket(CommPacket packet) {
              switch (packet.cmd) {
                case CommDef.ACK: ack = true;
    }CommTxRx actually does the reading and writing to the socket, and it is also a thread. It calls processPacket() when it recieves a new data packet
    public class CommTxRx extends Thread {
         private Socket socket = null;
        private ObjectInputStream in = null;
        private ObjectOutputStream out = null;
        private PacketReader reader = null;
        private boolean streamOk = false;
        public boolean abort = false;
        public boolean pause = false;
        public CommTxRx(Socket socket, PacketReader reader) {
          this.socket = socket; this.reader = reader;
        public void run () {
             try {
                in = new ObjectInputStream(socket.getInputStream());
              out = new ObjectOutputStream(socket.getOutputStream());
             } catch (IOException e) {
              System.err.println("Stream Setup Error");
              streamOk = false;
              return;
             streamOk = true;
             synchronized(this) {
                while(streamOk) {
                 try { this.wait(20); } catch (InterruptedException e) {
                          if (abort) close();
                 try {
                   if (in.available() != 0 && reader != null && !pause ) {
                        reader.processPacket(read());
               } catch (IOException e) { System.out.println("Read err"); }
                 catch (ClassNotFoundException n) {System.out.println("Read err CNF");}
        public CommPacket read() throws IOException, ClassNotFoundException  {
            if (!streamOk) return null;
            return (CommPacket) in.readObject();
        }Here is my question, is this actually going to work, calling the processPacket inside the ServerComm thread from the CommTxRx thread, and does the CommRxTx thread suspend until the code in the ServerComm thread completes. What I would like to do is when a packet arrives and is processed by processPacket, it sends a reply and then waits until an ack packet is received, that would mean a second instance of processPacket would have to be launched to change the ack boolean, that would be in a wait() loop in the first call to processPacket. Am I going to have to setup every processPacket as a thread also in order to make that happen or because I already have two threads running is that going to work. I have not written the code to do that yet, I would like to find out if it is going to work before I get that far.

              while(streamOk) {
              try { this.wait(20); } catch (InterruptedException e) {Pointless. Remove.
                   if (in.available() != 0 && reader != null && !pause ) {
                        reader.processPacket(read());Pointless. Remove. Just block in the readObject() method. If you want to poll, set a short read timeout.
    I don't see the need for this class & thread at all, it should all be folded into the previous one.

  • Cross Flash interaction

    I have a movie looping in one swf which I would like to
    control from another Flash movie. I want to tell the looping movie
    on click to stop and start another movie in the same flash

    do you want to communicate between two flash movies? if yes,
    please visit following links.
    http://www.actionscript.org/resources/articles/219/1/Communication-between-two-movies/Page 1.html

  • "Portable" way to do message passing between threads?

    (I posted this on the Apple Developer Forums already, but since that forum is only accessible to registered and paid iPhone developers, I thought it would be nice to put it here as well so as to get some more potential eyeballs on it. I apologize if this kind of "cross-posting" is not kosher/is frowned upon around here.)
    Hey everybody,
    "Long-time listener, first-time caller," heh.
    I've been working for the past 2-3 months on my very first iPhone app. Actually, what I've been working on is a framework that I plan to use in an iPhone app of my own but which I am also trying to write for the "lowest-common-denominator" so that I (and others) can use it in other apps written for both Mac and iPhone.
    Not only is this my first time writing an iPhone app, it is my first time writing for any Apple platform. In fact, it is my first time using Objective-C, period. I cannot stress this enough: I am a "n00b." So go easy on me. I also have not worked with threading before this, either, on any platform, so the learning curve for me here is rather significant, I'm afraid. I am NOT afraid of either taking the time to learn something properly OR of rolling up my shirtsleeves and working. However, on account of my experiences so far, I am finding myself (not to flame or anything!) quickly becoming frustrated by and disillusioned with not so much Objective-C itself, but the Foundation frameworks.
    So with that said, read on, if you dare...
    The basic idea behind my project is that the framework I am writing will present an API to developers which will allow them to write client apps that interact with a particular network appliance or network-aware embedded system. I already have my basic set of classes up and functioning, and the framework works to my satisfaction both on MacOS and iPhoneOS. The platforms I am targeting are MacOS X Tiger 10.4 and later, and iPhoneOS, and up until this point, I've managed to keep a codebase that works on all of the above.
    What I wanted to do next was add some multithreaded goodness to the mix. (Woe is me.) I have asynchronous network socket I/O working within the main thread, and it, in fact, works a treat. In my test app on the phone, I've managed to keep the UI nice and responsive by using the main thread's runloop efficiently. But even though TCP async I/O works fine within the main thread, I want to be able to split out and offload the processing of any data received by the app from the appliance to its own thread. (It is possible, and even desirable, for an application using this framework to be connected to multiple appliances simultaneously.)
    My idea, in order to try to keep things as simple and as clean as possible, was to implement a wrapper class that presented my other main class as an "actor." So, rather than instantiating my main class, one would create an instance of the wrapper class which would in turn control a single instance of my main class and spawn its own thread that the network connection and all data processing for that particular connection would run within.
    (I hope I'm making sense so far...)
    Out of the gate, writing a subclass of NSThread sounds like the logical design choice for an "actor-type" thread, but because I was trying to maintain Tiger compatibility, I stuck with +detachNewThreadSelector:etc.
    Once I decided to pursue the actor model, though, the main problem presented itself: how to best pass messages between the main thread and all of the "actor" threads that might be spawned?
    I stumbled upon -performSelector:onThread:withObject:, and knew instantly that this was exactly what I was looking for. Unfortunately, it doesn't exist on Tiger; only its much more limited little brother -performSelectorOnMainThread:withObject: does. So I kept looking.
    All of the pre-Leopard documentation, tutorials, and sample code that I read indicated that to pass messages between threads, I needed to basically pretend that the threads were separate processes and use the expensive Distributed Objects mechanism to get messages back and forth. Unfortunately, even if that WAS a desirable option, iPhoneOS does not have any support for DO! Grrr...
    Finally, I thought I found the answer when I ran into a third-party solution: the InterThreadMessaging library from Toby Paterson (available @ http://homepage.mac.com/djv/FileSharing3.html). In this library, the author basically implemented his own version of -performSelector:onThread:withObject: called -performSelector:withObject:inThread:. Sounds close enough, right? And actually, it is pretty darn close. It's made to do exactly what it sounds like, and it does it in a platform-neutral way that works on pre-Leopard systems as well as iPhoneOS, using Mach ports instead of DO.
    (...wellll, ALMOST. I discovered after I built a small test app around it that it actually isn't "iPhone-clean." The author used an NSMapTable struct and the NSMap*() functions, which don't exist in iPhoneOS, and he also implemented the handlePortMessage delegate method, but although iPhoneOS has NSPort, it DOESN'T have NSPortMessage. GAAARGH. So I took the time to replace the NSMapTable stuff with NSValue-wrapped objects inside of an NSMutableDictionary, and replaced the handlePortMessage method implementation with a handleMachMessage method, which took some doing because I had to figure out the structure of a Mach message, NO thanks to ANY of the available documentation...)
    Once I started using it, though, I quickly discovered that this implementation wasn't up to snuff. My "actor" class and my main thread will be passing a ton of messages to each other constantly whenever there is network activity, and with InterThreadMessaging, I found that whenever activity started to ramp up, it would collapse on itself. This mostly took the form of deadlocks. I found a note that someone else wrote after experiencing something similar with this library (quoted from DustinVoss @ http://www.cocoadev.com/index.pl?InterThreadMessaging):
    "It is possible to deadlock this library if thread A posts a notification on thread B, and the notification on B causes a selector or notification to be posted on thread A. Possibly under other circumstances. I have resolved this in my own code by creating an inter-thread communication lock. When a thread wants to communicate, it tries the lock to see if another thread is already using the InterThreadMessaging library, and if it can't get the lock, it posts a message to its own run-loop to try again later. This is not a good solution, but it seems to work well enough."
    So I tried implementing what he described using a global NSLock, and it did help with some of the deadlocks. But not all. I believe the culprit here is the Mach ports system itself (from the NSPortMessage documentation for -sendBeforeDate:):
    "If the message cannot be sent immediately, the sending thread blocks until either the message is sent or aDate is reached. Sent messages are queued to minimize blocking, but failure can occur if multiple messages are sent to a port faster than the portís owner can receive them, causing the queue to fill up."
    InterThreadMessaging in fact calls -sendBeforeDate: and exposes the deadline option, so I tried setting a really short time-to-live on the Mach messages and then intercepted any NSPortTimeoutExceptions that were thrown; upon catching said exceptions, I would then re-queue up the message to be sent again. It worked, but Performance. Was. A. Dog. At least the message queue wouldn't be full indefinitely anymore, causing the main thread to block, but during the whole time that these messages were expiring because the queue was full and then being re-queued, either the main thread was trying to send more messages or the actor thread was trying to send more messages. And as far as I can tell, the Mach ports queue is global (at the very least, there is seemingly only one per process). The message would get through with this model...eventually.
    JUST IN CASE the problem happened to be something I screwed up as I was rewriting portions of the InterThreadMessaging library so that it would compile and work on the iPhone SDK, I substituted in the original version of the library in my Mac test app to see if any of these problems became non-issues. I found that both versions of the library -- mine and the original -- performed identically. So that wasn't it.
    Finally, in frustration I said, "screw it, I'm going to try it the Leopard way," and replaced all of the method calls I was making to InterThreadMessaging's -performSelector:withObject:inThread: with calls to Foundation's native -performSelector:onThread:withObject: instead, changing nothing else within my code in the process. And wouldn't you know: IT WORKED GREAT. Performance was (and is) fantastic, about on-par with the non-threaded version when only dealing with a single connection/instance of my class.
    So, in the end, I was able to do nothing to salvage the InterThreadMessaging implementation of cross-thread method calling, and as far as I can tell, I'm out of (good) options. And thus my mind is filled with questions:
    How is the Leopard -performSelector:onThread: method implemented? I'm guessing not using Mach ports, given that I didn't have the same blocking & deadlocking problems I had with InterThreadMessaging. Is it possible to re-implement this Leopard+ method in a similar manner as a category to NSObject under Tiger? Or is it possible, perhaps, to increase the size of the Mach ports queue so that InterThreadMessaging works at a sane level of performance? Or -- I'm getting desperate here -- is there any way that I could trick -performSelectorOnMainThread: to target a different thread instead? (I am assuming here that -performSelectorOnMainThread is implemented under-the-hood much like the new -performSelector:onThread: is implemented, but with a hard-coded NSThread pointer built-in to the code, and that the new method just exposes a more flexible interface to what is basically the same code. I'm probably wrong...) Is there another third-party library out there that I've missed that fits my requirements for being able to do message-passing between threads in an efficient and portable manner?
    I refuse to believe that there is no way for me to maintain compatibility with all of the platforms I wish to support without having to resort to making preprocessor #ifdef spaghetti out of my code. And there SURELY has to be a better way of doing cross-thread message passing in Tiger without using Distributed Objects, for Pete's sake! Is this really how people did it for years-on-end since the dawn of NeXT up until the advent of Leopard? And if there really, genuinely wasn't another alternative, then what is up with the lack of DO in iPhoneOS?? Does Apple seriously intend for developers who have good, solid, tested and working code to just chuck it all and start over? What if there was some aspect of DO that previous implementations relied upon that cannot be recreated with simple -performSelector:onThread: calls? (I don't know what those aspects would be...just a hypothetical.) I mean, I can understand needing to write new stuff from scratch for your UI given how radically different the interface is between the Mac and iPhone, but having to reimplement back-end guts such as something as elemental as threads...really?!
    I do laud the inclusion of the new method in Leopard as well as the new ability to subclass NSThread itself. But for those of us that need to support Tiger for one reason or another, some of these restrictions and omissions within iPhoneOS seem like rather pointless (and frustrating) roadblocks.
    As I hope is obvious here, I have tried to do my homework before throwing up my hands and pestering y'all. If you have the patience to deal with me, please tell me what I am missing.
    Thanks for taking the time to read,
    -- Nathan

    Thanks again for your patience. Comments below.
    etresoft wrote:
    It is pretty unusual that anyone would want to call perfomrSelector on any thread other than the main thread.
    What I described in my original post was not a worker thread, but an "actor."
    It is hard for me to answer this question because there are so many options available to do "message passing". The fact that you think there are so few tells me that you really aren't sure what you need to use.
    I didn't say there were few options for message passing. I said there were few options for message passing that fit my criteria, which are that any potential solutions should both A) work efficiently and with good performance, and B) be available both pre-Leopard AND on the iPhone. -performSelector: ain't available before Leopard. Distributed Objects is overkill. Kernel Mach messages apparently have a high overhead, too, as my experience with the third-party library I wrote about in my original message shows.
    ...consider notifications.
    I thought notifications couldn't be posted across threads, either. How do I post a notification to another thread's default notification center or notification queue from a different thread?
    The notification center is owned by the process. Each run loop can listen for just the notifications it wants. You don't "pass" or "send" notifications, you run then up the flagpole for all to see.
    I am aware of how to use notifications. The documentation for NSNotificationCenter clearly states that "In a multithreaded application, notifications are always delivered in the thread in which the notification was posted, which may not be the same thread in which an observer registered itself."
    So, again, I don't see how one thread can post a notification in such a way that the observer's registered method is executed in another thread (posting notifications "across threads"). This probably isn't a big deal if you are using mutexes (assuming you don't actually care which thread carries out the task associated with the notification posting), but as I said before, this is not what I'm after.
    I don't know what you are really after.
    Allow me to attempt to explain a second time, in a more concise fashion.
    My app will have multiple, persistent TCP connections open, one connection per remote device. The user will be able to select a task to execute on a particular device that we have a connection open to, and get back from the application real-time updates as to the progress or results of the execution of that task. In certain cases, the length of the task is infinite; it will keep executing forever and sending back results to my application which will update its display of the results every second that ticks by until the user STOPS that particular task.
    This can be done simply using async I/O in the main runloop, sure. But if I were going to thread this so that I could be processing the results I've received back from one *or more* remote devices while also doing something else, given that I will only have one (persistent) connection open to any given remote device that I'm interacting with (that is to say, I won't be opening up a separate TCP session for every single task I want to execute on a single device simultaneously), it makes sense _to me_ to implement this as I've described: with every connection to each remote device getting its own thread that lasts for the lifetime of the TCP session (which could be the entire time the application is running, times however many devices the user wishes to be connected to while in the app). I won't be spawning a new thread for every task the user wishes to ask a remote device to do.
    This is why (I think) I need bi-directional messaging between the main thread and each of these threads dedicated to a given remote device that we have an active session with/connection to. The main thread needs to be able to tell remote device X (which already has a running thread dedicated to it) to do task A, and then get real-time feedback from that remote device so that the main thread can be displaying it to the user as it is coming back. Same with remote device Y running task B, simultaneously. At any time during the execution of these tasks, the user needs to be able to tell my app to stop one of these tasks, and the main thread needs to send that message to one of the remote devices via that device's dedicated thread.
    This is why I am talking about this in terms of the "actor model," and not the "worker thread model," because the former model seems to fit what I want to do.
    -- Nathan

  • Cross-reference auto-page numers?

    Can anyone tell me why i cannot get cross-references to work with  automatic page numbering?  Is there some fundamental error i am  making?  I have the master files setup with auto-page numbering based on  'current page.'  All of my pages are numbered sequentially as 1, 2, 3,  etc. and setup with a unique paragraph style.  however, when i try to  reference a page number in the document, none of the pages show up under  the paragraph style in the cross-reference menu.  I have even tried to  use ctrl+shft+click on the desired reference page to bring the page number frame  from the master file onto that specific page, but the text still does  not show up in the cross-references menu.  I feel as though i must be  making some sort of mistake because it seems this could be one of the  more obvious/widespread uses for the cross-reference feature.  Any help  would be great.  Perhaps there is simply another way to do  this?  Thanks!
    Garrett

    GarrettTV wrote:
    Peter,
    I understand that this is probably a more specific use of the feature, no doubt.  It is ultimately unrealistic to expect a program to work exactly as each individual user's project approach dictates.  I dont take the comment as a slam, dont fret.
    My confusion and concern ultimately stems from the fact that, on the surface (granted, I am definitely not a programmer ), it seems like the ability to directly reference the page number would be, almost inherently, already built-in in the sense that the page number is recognized as a product of content placement.  In other words, if the cross-reference knows that changes to the document composition have caused my referenced content to move from auto-numbered page 36 to auto-numbered page 37, yet the reference cannot exist to simply the page number itself.  It has to exist via the content on taht page.  Hopefully I have provided and explanation which makes sense!
    In all honesty, the ability to reference only content and not also page number is only goingot set me back about half.  For my sake, I have a 300 page document which includes hundreds of figures/illustrations, all of which correspond to text explanations in a different part of the document.  Over time, it is anticipated that standards and graphics will be added/subtracted/changed, and therefore, so will the section numbering, page numbering, figure numbering, and the corresponding pages on which all of these pieces of info will occur.  We would like to correspond figures and sections to one number; in this case, the page.  Because each figure/illustration will have it's own page, it is desired to make the figure number and page number match to achieve an easier means of navigating the book.  Basically, I want the text section, which will be read first, to reference figure numbers and/or page numbers (at this point, i have the option of choosing one or the other), but both of these numbers are going to dynamically update.
    So, if that made any sense at all (ha), is there a way to use the cross references to point at a number that is set to automatically/dynamically change?  If there is not, then perhaps I will simply have to create static figure numbers for the referenced content and then just let the page numbers change over time.  If you have any other suggestions, I am definitely open to exploring them!
    Thanks for the continued help!
    Garrett
    Hi, Garrett:
    If I understand your description correctly, it seems that you're asking for an unusual numbering/navigation approach. Is there an example that you've seen that works this way, and that you want to emulate? Is this a publishing style/convention in the particular industry?
    Am I correct in imagining that in a document that contains three figures on discontiguous pages, they might be numbered something like this:
    Page #
    Figure #
    1
    1
    15
    15
    250
    250
    This would result in no figures 2, 3...14...249. Would your document have references to figure 15 on page 15? Would you want your list of figures (LOF) to resemble:
    Figure  number and title                                                     Page     
       1.  Example of the widget in question .............................    1
    15.  Example of another widget .........................................  15
    (sorry about the messy table layout - the HTML is tricky)
    Would your audience be concerned that the figure numbers are not consecutive across a multi-chapter book, or consecutive within a chapter, and restart in each chapter? That is, would a reader think that some figures are missing?
    Is there a specific objection to figure 11 on page 26 becoming figure 11 on page 28, if text content were inserted, or becoming figure 16 on page 29 if figures were inserted? When numbered-list paragraph styles and cross-reference formats are set up properly, cross-references to these figures would update to indicate both the correct number and correct page.
    Have I misunderstood something?
    [EDIT]
    I forgot to ask if your document will be using cross-references interactively in a PDF or other multimedia format. If so, can you give more detail on your expectations?
    Have you looked into InDesign hyperlinks? They can refer to a page number - either "sticking" to the designated page no matter if its page number changes because of reflow or being moved, or "sticking" to whatever happens to become the "n-th" page if the original page is relocated. Search Help for Create a hyperlink to a page.
    [/EDIT]
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices
    Message was edited by: peter at knowhowpro

  • Interactive report performance problem over database link - Oracle Gateway

    Hello all;
    This is regarding a thread Interactive report performance problem over database link that was posted by Samo.
    The issue that I am facing is when I use Oracle function like (apex_item.check_box) the query slow down by 45 seconds.
    query like this: (due to sensitivity issue, I can not disclose real table name)
    SELECT apex_item.checkbox(1,b.col3)
    , a.col1
    , a.col2
    FROM table_one a
    , table_two b
    WHERE a.col3 = 12345
    AND a.col4 = 100
    AND b.col5 = a.col5
    table_one and table_two are remote tables (non-oracle) which are connected using Oracle Gateway.
    Now if I run above queries without apex_item.checkbox function the query return or response is less than a second but if I have apex_item.checkbox then the query run more than 30 seconds. I have resolved the issues by creating a collection but it’s not a good practice.
    I would like to get ideas from people how to resolve or speed-up the query?
    Any idea how to use sub-factoring for the above scenario? Or others method (creating view or materialized view are not an option).
    Thank you.
    Shaun S.

    Hi Shaun
    Okay, I have a million questions (could you tell me if both tables are from the same remote source, it looks like they're possibly not?), but let's just try some things first.
    By now you should understand the idea of what I termed 'sub-factoring' in a previous post. This is to do with using the WITH blah AS (SELECT... syntax. Now in most circumstances this 'materialises' the results of the inner select statement. This means that we 'get' the results then do something with them afterwards. It's a handy trick when dealing with remote sites as sometimes you want the remote database to do the work. The reason that I ask you to use the MATERIALIZE hint for testing is just to force this, in 99.99% of cases this can be removed later. Using the WITH statement is also handled differently to inline view like SELECT * FROM (SELECT... but the same result can be mimicked with a NO_MERGE hint.
    Looking at your case I would be interested to see what the explain plan and results would be for something like the following two statements (sorry - you're going have to check them, it's late!)
    WITH a AS
    (SELECT /*+ MATERIALIZE */ *
    FROM table_one),
    b AS
    (SELECT /*+ MATERIALIZE */ *
    FROM table_two),
    sourceqry AS
    (SELECT  b.col3 x
           , a.col1 y
           , a.col2 z
    FROM table_one a
        , table_two b
    WHERE a.col3 = 12345
    AND   a.col4 = 100
    AND   b.col5 = a.col5)
    SELECT apex_item.checkbox(1,x), y , z
    FROM sourceqry
    WITH a AS
    (SELECT /*+ MATERIALIZE */ *
    FROM table_one),
    b AS
    (SELECT /*+ MATERIALIZE */ *
    FROM table_two)
    SELECT  apex_item.checkbox(1,x), y , z
    FROM table_one a
        , table_two b
    WHERE a.col3 = 12345
    AND   a.col4 = 100
    AND   b.col5 = a.col5If the remote tables are at the same site, then you should have the same results. If they aren't you should get the same results but different to the original query.
    We aren't being told the real cardinality of the inners select here so the explain plan is distorted (this is normal for queries on remote and especially non-oracle sites). This hinders tuning normally but I don't think this is your problem at all. How many distinct values do you normally get of the column aliased 'x' and how many rows are normally returned in total? Also how are you testing response times, in APEX, SQL Developer, Toad SQLplus etc?
    Sorry for all the questions but it helps to answer the question, if I can.
    Cheers
    Ben
    http://www.munkyben.wordpress.com
    Don't forget to mark replies helpful or correct ;)

  • Cannot Open Form Created on Separate Thread After Closing

    My application communicates with a device that has several sensors.  As the sensors collect data, they send messages over the com port.  I have written a class to communicate with the device.  As the messages come in and are processed, the
    class raises events that the application responds to.
    The main window of the application handles the communication with the device and displays several statistics based on the data collected.  When the user presses a button on the device, a specific event is raised.  The main window create a separate
    thread and opens a child window.  When the child window is open, the user opens a valve to dispense the product.  As the product is dispensed, a flow meter connected to the device measures the volume of product dispensed.  The flow meter generates
    messages to indicate the volume dispensed.  I need to be able to send messages from the main window to the child window so that the child window displays the volume.  When the user is done, they close the valve dispensing the product and press the
    "End" button on the child window.  The child window then updates several variables on the main window, makes a couple of database calls to record how much product was dispensed and by whom and then closes.
    I need to run the child window using a separate thread as both windows need to be able to process commands.  If only one window has control the program doesn't work at all.  I have it figured out so that everything is working.  I can open
    the child window, dispense product, se the amount of product dispensed in the child window (the main window processes commands from the device and updates the label on the child window using a delegate), closes the window (using Me.Close()) and updates the
    main display with the updated data.  The problem is that when a user goes to dispense product a second time, I get the following error:
      A first chance exception of type 'System.ObjectDisposedException' occurred in System.Windows.Forms.dll
      Additional information: Cannot access a disposed object.
    I thought that maybe I could hide the window (change Me.Close() to Me.Hide) and then just show it.  When I do that I get this error:
      A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
      Additional information: Cross-thread operation not valid: Control 'frmPour' accessed from a thread other than the thread it was created on.
    Both of these errors make sense to me, I just can't figure out how to make it work.
    First I have to declare the child window as a global variable as I need to access the window from a couple of the event handlers in the main form.
    Public frmMeasure As New frmPour
    When the user presses the button on the device to dispense the product, the event handler executes this code to open the child window.
    Private Sub StartPour(sAuthName As String, sAuthToken As String, iStatus As Integer) Handles Device.Pour
    Dim th As System.Threading.Thread = New Threading.Thread(AddressOf Me.OpenDispenseWindow)
    th.SetApartmentState(ApartmentState.STA)
    th.Start()
    End If
    End Sub
    Which executes this code:
    Public Sub OpenDispenseWindow()
    frmMeasure.sNameProperty = sCurrentUserName
    frmMeasure.sAuthTokenIDProperty = sUserToken
    Application.Run(frmMeasure)
    bAuthenticated = False
    bPouring = False
    dSessionVolume += GetTapConversion(sCurrentValve) * iFinalTick
    UpdateDisplayDelegate(iValveID)
    End Sub
    It doesn't matter if I use Me.Close() or Me.Hide(), both methods fail on the Application.Run(frmMeasure) line with the errors shown above. 
    For the Me.Close() method, my thinking is that the global frmMeasure object is getting disposed when I close the child window.  Is there any way that I can re-instantiate it when I go to display the window again?
    For the Me.Hide method, is there any way that I can track the thread that created it in the main window and when I go to call it a second time, detect that it is already available and just Show() it?
    Any hints, tips or suggestions are appreciated.
    Thanks.
    John
    John

    To be honest, I have only grasped < 100% of your message in detail, but...: Windows that have a parent<->child relation must be running in the same thread. In addition, after closing a modeless window, you must not use it anymore. Instead, create
    a new instance.
    What happens if you do not create a new thread but instead open the child in the same thread (which is obligatory)? You wrote it doesn't work, but I don't know why?
    "First I have to declare the child window as a global variable".
    How do you define "global"? Normally this is a variable in a Module declared with the scope Public or Friend. But I guess you mean a field of the Form (a variable at class level in the Form).
    "I need to be able to send messages from the main window to the child window so that the child window displays the volume."
    Why does the main window has to send the messages? Can't the child window handle the device's messages itself?
    "I need to run the child window using a separate thread as both windows need to be able to process commands."
    Process commands from the device, or commands from the user operating the Forms?
    Armin

  • Interactive report : issue with french special characters

    Hi,
    We have many interactive reports and we can't use any french special characters in the filter clauses. For example, Montréal becomes montréal.
    What parameters do we have to change to make it work?
    Thanks.

    I found the answer in this thread : Interactive Report Character Set Issue

  • Threads treading on one another's feet...

    Dear All,
    I wonder whether you could help me with a couple of threads treading on one another's feet.
    Following is the class in question, which represents a sort of simple semaphore on object locking. The only two states allowed should be 0 and 1, respectively available and not available. (just for study purposes) immagine then Thread1 and Thread2 calling both acquire() and release() in their run() methods.
    <code>
    public class Atomic {
    private volatile int semaphore = 0;
    public void acquire() { semaphore = semaphore + 1; }
    public void release() { semaphore = semaphore - 1; }
    </code>
    and this is the javap -c Atomic result:
    <code>
    Compiled from Atomic.java
    public class Atomic extends java.lang.Object {
    public Atomic();
    public void acquire();
    public void release();
    Method Atomic()
    0 aload_0
    1 invokespecial #1 <Method java.lang.Object()>
    4 aload_0
    5 iconst_0
    6 putfield #2 <Field int semaphore>
    9 return
    Method void acquire()
    0 aload_0
    1 aload_0
    2 getfield #2 <Field int semaphore>
    5 iconst_1
    6 iadd
    7 putfield #2 <Field int semaphore>
    10 return
    Method void release()
    0 aload_0
    1 aload_0
    2 getfield #2 <Field int semaphore>
    5 iconst_1
    6 isub
    7 putfield #2 <Field int semaphore>
    10 return
    </code>
    When two threads interact on this particular object, the possible values for semaphore held in an unstable state are 2 and -1.
    If it's quite simple to account for 2, it's not so for -1.
    I would like to understand why. Furthermore, I have just approched opcodes, so don't take anything for granted, please.
    One more question: are incrementing and decrementing atomic operations, is then every single opcode an atomic operation?
    P.s. and the purpose of volatile in case?
    Thank you for your time
    luca

    It may be best to include the full example (from Eckel's Thinking in Java):
    //: c13:Invariant.java
    public interface Invariant {
    InvariantState invariant();
    //: c13:InvariantOK.java
    // Indicates that the invariant test succeeded
    public class InvariantOK implements InvariantState {}
    //: c13:InvariantFailure.java
    // Indicates that the invariant test failed
    public class InvariantFailure implements InvariantState {
    public Object value;
    public InvariantFailure(Object value) {
    this.value = value;
    //: c13:Semaphore.java
    // A simple threading flag
    public class Semaphore implements Invariant {
    private volatile int semaphore = 0;
    public boolean available() { return semaphore == 0; }
    public void acquire() { ++semaphore; }
    public void release() { --semaphore; }
    public InvariantState invariant() {
    int val = semaphore;
    if(val == 0 || val == 1)
    return new InvariantOK();
    else
    return new InvariantFailure(new Integer(val));
    //: c13:SemaphoreTester.java
    // Colliding over shared resources
    public class SemaphoreTester extends Thread {
    private volatile Semaphore semaphore;
    public SemaphoreTester(Semaphore semaphore) {
    this.semaphore = semaphore;
    setDaemon(true);
    start();
    public void run() {
    while(true)
    if(semaphore.available()) {
    yield(); // Makes it fail faster
    semaphore.acquire();
    yield();
    semaphore.release();
    yield();
    public static void main(String[] args) throws Exception {
    Semaphore sem = new Semaphore();
    new SemaphoreTester(sem);
    new SemaphoreTester(sem);
    new InvariantWatcher(sem).join();
    When I run the programme on my Pentium 133 with Windows 95, the InvrianteWatcher
    detects the semaphore's value in an invalid state (2). If you remove all the yields() withing the run() method
    the InvariantWatcher detect -1. What I'd like to know is the sequence of opcodes (the mixing of both threads)
    that would set semaphore's value to 2 and -1.
    I would be grateful if you could be as thorough as possible in your explanaition.
    I only trying to get a deeper understanding of the underlaying logic of threads.
    Many thanks
    Luca

  • Threads Question/Opinion

    I am currently developing an application that will create a process. The process itself will be cmd.exe with parameters. The application is Swing based and so I don't lock the event dispatch thread, I created a thread that will create the process. I also know that when using cmd.exe it is important to handle the inputstream and errorstream so the whole process does not lock. The examples I've seen for handling these streams where handled in threads of their own so they could be processed at the same time. My question is this: In your opinion would it be better to handle the process and streams in one thread, or should I create one thread to create the process and 2 threads to handle the streams (1 thread for each stream)? I think the multiple threads (essentially 3 for one process) will negatively impact the applications performance, but I don't know if handling the streams in a function/method within one thread would be adequate enough to keep the app from deadlocking. Any ideas?

    I had read that multiple threads can cause more
    e overhead and slow performance of the application in
    general. The article just said more threads=more
    overhead, Fair enough. That's true as far as it goes, but I can't imagine 3 threads ever causing any detectable problem, unless each thread is something like this public void run() {
        someField_++;
        Thread.yield();
    } It's not uncommon to have tens of threads, and I've created thousands in little dummy test programs and not noticed performance problems.
    I didn't have an exact number to work with
    and that was my concern. I believe the threads I was
    thinking of would perform the needed actions quickly
    and therefore not impact performance too much, but I
    wanted to be sure. The key is that each thead does enough at one time so that the overhead of switching is small compared to the work done, but also making sure that no thread hogs the CPU for too long. If you're doing I/O, then each call to read has the potential to let another thread have a turn, I believe. Otherwise it's common to put a call to yield in your thread's main loop. Maybe every iteration, maybe every 10 or 100 or whatever, depending on what that iteration does.
    If you have tasks that can be handled in parallel--indpendently of one another--or should be independent to prevent one from forcing another to wait (like reading two streams) then you should give those tasks separate threads. Once you have that working correctly, then if you have measured performance problems relating to how those threads interact or take turns (or don't take turns) then you can tweak the code to try to optimize that aspect of it.
    I am teaching myself Java and its
    been a bit of a haul. I appreciate the help and
    information I get from these forums hence this
    posting.Cool. Glad to be of help.

  • Pass messages between main thread and FX application thread

    I'm launching an FX Application thread from a Main thread using Application.launch [outlined here: {thread:id=2530636}]
    I'm trying to have the Aplication thread return information to the Main thread, but Application.launch returns void. Is there an easy way to communicate between the Main thread and the Application thread?
    So far I have googled and found:
    - MOM (Message Orientated Middleware)
    - Sockets
    Any thoughts/ideas/examples are appreciated - especially examples ;) - right now I am looking at using Sockets to show/hide the application and for passing data.
    What is the preferred method? Are there others which I have not found (gasp) via Google?
    Dave.
    Edited by: cr0ck3t on 30-Apr-2013 21:04
    Edited by: cr0ck3t on 30-Apr-2013 21:05

    Is there an easy way to get a reference to these objects from both the Main thread and the FX Application thread - called via Application.launch() from the Main thread? Or do I have to use Sockets or MOM?Not much to do with concurrent programming is what I would call easy. It seems easy - but it's not.
    You can kind of do what you are describing using Java concurrency constructs without using sockets or some Message Oriented Middleware (MOM) package.
    With the Java concurrency stuff you are really implementing your own form or lightweight MOM.
    If you have quite a complex application with lots of messages going back and forth then some kind of MOM package such as camel or ActiveMQ (http://camel.apache.org) is useful.
    You can find a sample of various thread interactions with JavaFX here:
    https://gist.github.com/jewelsea/5500981 "Simulation of dragons eating dwarves using multiple threads"
    Linked code is just demo-ware to try out different concurrency facilities and not necessarily a recommended strategy.
    If your curious, you could take a look at it and try to work out what it is, what it does and how it does it.
    The main pattern followed is that from a blocking queue:
    http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/BlockingQueue.html
    Note that once you call launch from the main thread, no subsequent statements in the main method will be run until the JavaFX application shuts down. So you can't really launch from the main thread and communicate with a JavaFX app from the main thread. Instead you need to spawn another thread (or set of threads) for communication with the JavaFX app.
    But really, in most cases, the best solution with concurrency is not to deal with it at all (or at least as little as possible). Write everything in JavaFX, use the JavaFX animation framework for timing related stuff and use the JavaFX concurrency utilities for times when you really need multiple thread interaction.
    http://docs.oracle.com/javafx/2/threads/jfxpub-threads.htm
    To get further help, you might be better off describing exactly (i.e. really specific) what you are trying to do in a new question, perhaps with a sample solution in an sscce http://sscce.org

  • How to increase rowcount on clicking on Interactive page header

    Hi All,
    I have create Interactive report on table which has more than 3 Lakhs records. If click on Document Name it showing only 1000 distinct names.
    Where can I increase these value to sort and see the all values.
    Apex version 3.2
    Thank,
    NR

    Hi,
    For performance reason it will only show first 1000 distinct values when you click on ir report headers, you cannot increase it.
    You can workaround this by going into Actions > Filter
    I suggest to follow this active thread Interactive Report (IR) column heading: filtered items number & flashlight
    Thanks

  • Adobe Photoshop CS3 Extended freezes on startup under Windows 7 Ultimate 64-bit - No splash screen

    I installed my licensed copy of Adobe Photoshop CS3 Extended today as part of my install a bunch of software after a reinstall of Windows (due to viruses).  I did a completely fresh install of Windows 7 Ultimate 64-bit.  I've used Photoshop CS3 Extended for quite a while now so I know what to expect on startup but it was previously installed under Windows XP Professional (32-bit). Figured I would give Windows 7 a chance this time around.
    Google searches aren't turning up anything.  When I attempt to start the application, I get a window with the title "Adobe Photoshop CS3" (no "Extended" - I seem to recall the title changes later) and the toolbar appears.  However, no splash screen appears and no Product Activation wizard appears - the application simply freezes on an empty frame and a toolbar.  I've tried running Photoshop as Administrator (right-click, "Run As Administrator"), but nothing changed there.  I tried uninstalling and reinstalling.  I tried upgrading to CS3 10.0.1.  Nothing works.  The application simply freezes before it gets anywhere.
    I tried calling Adobe Support since this technically falls under installation issues but their phone support systems are down today.  Go figure.
    Edit:  I hooked into Photoshop with the Visual Studio debugger and every single thread is executing some variation of WaitForSingleObject() or WaitForMultipleObjects().  The main thread is "executing" somewhere in AdobeLM_libFNP.dll (at address 09619d81 - if I had debugging symbols for CS3, I could provide a function).  There are nine threads "running" at the point the freeze occurs - but all of them are technically suspended due to the functions they are executing - and one thread is in a suspended state.

    Log Name:      Application
    Source:        Application Hang
    Date:          7/17/2010 6:16:25 PM
    Event ID:      1002
    Task Category: (101)
    Level:         Error
    Keywords:      Classic
    User:          N/A
    Description:
    The program Photoshop.exe version 10.0.1.0 stopped interacting with Windows and was closed. To see if more information about the problem is available, check the problem history in the Action Center control panel.
    Process ID: d0c
    Start Time: 01cb2616be79e36f
    Termination Time: 2
    Application Path: C:\Program Files (x86)\Adobe\Adobe Photoshop CS3\Photoshop.exe
    Report Id: 06f5fbff-920a-11df-9d69-001fd023417e
    Event Xml:
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
      <System>
        <Provider Name="Application Hang" />
        <EventID Qualifiers="0">1002</EventID>
        <Level>2</Level>
        <Task>101</Task>
        <Keywords>0x80000000000000</Keywords>
        <TimeCreated SystemTime="2010-07-18T01:16:25.000000000Z" />
        <EventRecordID>1615</EventRecordID>
        <Channel>Application</Channel>
        <Security />
      </System>
      <EventData>
        <Data>Photoshop.exe</Data>
        <Data>10.0.1.0</Data>
        <Data>d0c</Data>
        <Data>01cb2616be79e36f</Data>
        <Data>2</Data>
        <Data>C:\Program Files (x86)\Adobe\Adobe Photoshop CS3\Photoshop.exe</Data>
        <Data>06f5fbff-920a-11df-9d69-001fd023417e</Data>
        <Binary>430072006F00730073002D0074006800720065006100640000000000</Binary>
      </EventData>
    </Event>
    And, according to the Event Viewer, the "Binary" data translates to a zero-terminated Unicode string of "Cross-thread".
    My Visual Studio analysis was far more informative.  All threads are hung inside of WaitForSingleObject() and WaitForMultipleObjects() calls and the DLL in question appears to be FlexNet-related.  I did forget to mention that I also even manually started the FlexNet service in case, for some strange reason, Photoshop was waiting for it to start.  That also did not work.
    (And there is nothing in the Action Center control panel either despite the message saying there might be more information there.)
    Edit:  The timestamp above might be a little odd-looking.  I didn't originally see anything in Event Viewer until I clicked the first button to send an Error Report.  Mostly I just skipped that part of killing a process.

  • CRM 2007 CIC Architecture

    Hi All,
    Can you please let me know any link for current CRM 2007 architecture.
    Moreover CRM 2007 CIC Architecture - any SAP standard info available.
    I know cross posting is very bad habit, but by mistake I posted in CRM 2007 instead of this community.
    Sorry.
    Regards,
    Jitender

    Hello Jitender,
    When you refer CIC do you mean IC Winclient?
    If so, unfortunally winclient is no longer supported in that version. The only Interaction Center that is supported in that version is the IC WebClient.
    For more details, check John Burton answer in the following thread:
    Interaction Center WinClient in CRM 6.0?
    Kind regards,
    Bruno

Maybe you are looking for

  • Re-name and add security

    I set up my WRT54G without naming my network nor setting up the network to be secure.  It is running perfectly but I would like to rename my network and make it password protected (secure.)   When I get to the second step it asks me for my password. 

  • Mouse Pointer Speed vs. Resolution

    Greetings, I've purchased the HP 2.4GHz Wireless Optical Mobile Mouse. In the Mouse Control Center, I have the option of setting the Pointer Speed (slow to fast) and Resolution (low to high). What is the difference between pointer speed and resolutio

  • Characteristics validations in BPS

    I have a question related to characteristics validation in BPS. Is it true that the validation is not executed if any one of the involved characteristics have unassigned value? We have two characteristics: Account and “Trading partner” in the validat

  • Set location in Reminders by tap

    Reminders.app allows to notify on location (arriving or leaving). But when location sets it cannot be selected by tap on the map. Only by writing address via search field. Is there app restriction or my iPhone fault?

  • Premiere Pro CC - File Size

    Please help me! I am working on a QuickTime video that was 45 MB 49 minutes long. I trimmed three simple areas (beginning, a tiny piece in the middle, then the end) and after it's a 46 minute video that ended being a 1,681 file size! I have attached