Multithreading in multiple VM enviorment

I'm writing a client server application which makes extensive use of rmi.
There are times when I have to synchronize access to certain resources.
The problem is that if, during a remote method invocation, the remote client VM crashes, the lock will not be released.
I came up with the following solution.
Each relevant method invocation will add a "task" into a queue of some sort.
On the server, a dedicated thread which is spawned by its own VM, will look into the queue and execute the "tasks". So if the remote client VM crashes, it won't cause a deadlock. And if the server application crashes, well then, deadlock is the least of my problems.
I'd like to hear your comments or other ideas if you have them.

I'm confused about your model. Are you talking about clients making lock/unlock requests? Or perhaps starting/ending transactions? That's the only way I could figure a client crash would cause the problem you describe.
Here's an idea for dealing with this:
o Define a timeout period for each resource lock. Or - if you prefer - have the client program ask for the period it wants to lock a resource.
o When a request comes in, lock the resource.
o When another request for the same resource comes in, examine "now" vs the time of the last resource request + the timeout period. If the timeout has expired, grant the new request.
(No muss, no fuss, no extra threads/timers/queues/etc.)
If you are NOT talking about client lock/unlock/start transaction/end transaction requests, then client calls are atomic, and a client crash should have no effect on the server.

Similar Messages

  • Not Able to create ADF Table In the Multiple model enviorment

    Hi All
    I am not able to create ADF Table or ADF Read-only Table
    I am having following thinks in my JWS Project
    2, Model Project(Different different name)
    2,faces-config.xml(Different different name)
    1 web Project (View Controller)
    and one Databinding.cpx file
    i am using following version of jdeveloper to develop application
    ADF Business Components     10.1.3.41.57
    BPEL Designer     10.1.3.3.0 (Build 070615.0525)
    Java(TM) Platform     1.5.0_06
    Oracle IDE     10.1.3.41.57
    Struts Modeler Version     10.1.3.41.57
    UML Modelers Version     10.1.3.41.57
    Versioning Support     10.1.3.41.57

    Are you dragging from the data control? what technologies did you use for the data controls?Ans:I am using data controll as ADF BC
    Are the two faces-config.xml files in your web project?
    Ans:Yes with one name with faces-config.xml and antoher with different name

  • Multithreading on multiprocessors

    hi,
    can anyone help me in finding out how i can do multithreading on multiple processors in Java.
    Does the stabdard sdk provide or do we have to download third party software?
    Thanks in advance

    Hi luke,
    If you're using a recent JVM (i.e. the Hotspot VM)the
    number of processors you have on your machine
    shouldn't be an issue (these jvm's have been testedon
    30+ cpu machines). The only thing you might have to
    worry about is a garbage collection bottleneck when
    you're using a large numbers of processors.Since the GC Thread being the low priority thread it
    will come in picture once all high priority threads
    are done or if there is the requirement of the memory
    which can be collected by the GC.Once we have
    multiple CPU then there is the probability that of
    getting the gc being called frequently but how it can
    cause a bottleneck?
    What I mean to say is that with more number of
    processors there is more probability of calling the
    GC Thread than the lesser number of processors. Both
    ways the GC has to get called but in earlier case the
    processing with JVM will be fast and with later it
    will be comparatively slower.
    Regards
    VickyMost jvm's use a single-threaded copying collector, and (quoted from the hotspot 1.4.1 white paper) "this could become a bottleneck to scaling in an application that is otherwise parallelized to take advantage of multiple processors".
    However, the new 1.4.1 Hotspot jvm does have an optional multithreaded collector (tested against more than 100 cpu's and 0.5 terabytes of heap) that uses multiple threads working in parallel (and lots of other clever stuff) to improve performance on multiple processor machines.

  • Yet another high cpu using flash issue

    Salutations. What I'm about to tell you won't come to you as a surprise as there have been many similar topics discussed here. In fact, on the first page, there were two. So let's get on with it!
    hp pavillion entertainment notebook dv6 e2170ee
    windows 7 64bit
    6gb ram
    intel core i7 cpu q 720 @ 1.60 GHz    (never overclocked. don't know how to)
    nvidia geforce gt 230m
    firefox is on safe mode. kind of better than regular mode.
    firefox waaaay better than chrome in handling flash. haven't tried it on ie. don't want to. i left ie8 at version 8
    flash hardware accelration is off
    firefox hardware accelaration is on
    latest flash player enabled
    latest shock player enabled
    latest flash director enabled
    latest firefox
    no idea if my vents and cooling system work properly. read several posts about this issue being related to hardware.
    i have updated my drivers using hp support assistant, driver detective, and windows update. wouldn't be surprised if there was a conflict with all this nvidia driver as well. went to the site. it detected my model and sent me the driver. had audio and video options in it.
    while writing this post, the adobe tab + 4 flash tabs off the same site (youtube, younow, cam sites, etc) are open.
    performance tab in taskbar says
    flashplayer 15 *32bit (2 processes with the same name but diff cpu usage by the way. why 2?) is using 5%
    firefox *32 bit is using 5%
    audiodg.exe is nowhere to be found
    now firefox and flashplayer keep alternating ofcourse. flash always ends up with higher cpu when everything breaks. i have noticed that even after closing ff, ff and flash are still in the processes table. they stay there for a bit. why?
    ISSUE NUMBER 1: i can't play a video and have flash players on at the same time. I'd like to watch a movie and every now and then look to my other screen to see what's going on with the flash site. it can't be done. all is well at the beginning then it goes to hell. i have the latest free version of bsplayer and videolan. Yes vlc handles better but it all goes to hell in the end. sometimes the video won't even show on vlc; only audio
    ISSUE NUMBER 2: i don't understand the logic behind the increase in cpu. if i have 6 tabs open all flash all is well. but at some point it just spikes up. so i always try to keep the number of flash tabs as low as possible. sometimes 4 are no issue but 5 are a big issue. sometimes closing a tab helps and sometimes it doesnt.
    ISSUE NUMBER 3: audiodg starts using more than 2%. It can go up to 11 or 13 even. That shouldn't happen. I've been told that for it to go beyond 2 or even 3 means there's a conflict. I had trouble dealing with this issue. I don't know what or where the conflict is. So if there's anyone here that's good at this please contact me. Ill post a pic of device manager. For the sound, i have 4 nvideo and 1 idt audio codec. I cdon't know which to disable or uninstall. im thinking of unintalling every audio/video driver i hav and start from the beginning. BUT LETS NOT MAKE THIS ABOUT AUDIO/VIDEO CONFLICT
    QUESTION 1: was there ever a time when this issue didn't exist? perhaps there's a "stable" version of ff or flash that don't cause this.
    QUESTION 2: ive seen a lot of posts about this but I honestly can't remember any participants saying OH REALLY? ODD, I NEVER HAD THIS ISSUE BEFORE
    QUESTION 3: isn't there some kind of tracer that can track the moment that it goes to hell? im sure there is but no one's mentioned it so far
    QUESTION 4: would buying a new laptop solve this? I'd like to think not since the issue is flash not the capabilities of a laptop but i can't help but think that a better laptop will fix this. My laptop is 4 years old.
    QUESTION 5: i don't know anything about multithreading or multiple cores handling a single process but if someone showed me how, would that resolve my issue?
    MY WISH: for flash to coexist peacefully with human beings

    Disabling Hardware Acceleration in Flash means that we're doing all of the processing on the CPU, instead of on the GPU.  The GPU is purpose-built for 3D graphics and video decoding and is far more power efficient.  Decoding H.264 video in software is very CPU intensive, which is why we made the huge investment to enable hardware acceleration on the vast majority of available desktop hardware. Running six CPU intensive tasks simultaneously (which is what you're doing by using six simultaneous tabs) is unsurprisingly going to tax your machine.
    If you've disabled Hardware Acceleration because video wasn't working right or something, figuring out how to get that enabled (or moving to better hardware with good driver support) would solve the vast majority of what you're describing here.  If HP doesn't offer updated drivers, I'd recommend trying the corresponding Nvidia drivers, as OEMs aren't always motivated to pick up the latest fixes once a model is no longer generating new revenue for them.  The chipset manufacturers tend to provide longer support, but those drivers aren't officially supported by the OEM.
    The architecture for Protected Mode for Firefox is a result of the fact that we've retrofitted a modern plug-in security approach to a legacy plug-in architecture.  As you've noticed, equivalent sandboxing in other major browsers is designed into their plug-in architectures, and is therefore more efficient.  We've made huge investments to support modern security architecture and always do our best to accommodate efforts from our partners in the browser space to further secure the browser.  You can find a detailed explanation of our approach to Firefox here: Inside Flash Player Protected Mode for Firefox
    Firefox controls the instantiation and destruction of Flash instances.  You'll also notice that Firefox hangs out for a while after shutdown.  This is something that we're aware of, but it's beyond our control.
    Flash doesn't have much to do with audiodg, except for the fact that it generates sound and uses the windows sound subsystem.  This article seems to present some reasonable advice in resolving issues with high CPU consumption from the sound subsystem.  Fix Audiodg.exe High CPU Usage in Windows 7 | Windows EXE Errors
    Hardware accelerated video encoding is typically not available on consumer-grade hardware (primarily because of the difference in licensing models for encoding and decoding with popular commercial codecs), and therefore is done on the CPU.  The particular website chooses what codecs and bitrates are involved, and higher quality feed will consume more CPU.  It's also worth pointing out that not all video can be decoded in hardware.  We provide clear guidance to content providers on how to encode video so that it can be played back efficiently, it's ultimately up to the content provider to follow that advice.
    So, long story short, each tab consumes resources.  Running a single tab is going to use less resources than running multiple tabs.  The latest version of Internet Explorer does some stuff to reduce resource consumption in tabs that you're not actively looking at.  We're discussing possibilities with the Chrome folks for doing the same thing in Chromium-based browsers.  Mozilla isn't interested in investing in browser plug-ins, so we don't expect to see the necessary browser-side improvements there.  The Chrome sandboxing model is more efficient that protected mode for Firefox, so tasks that require moving a lot of data (like streaming video) may use less CPU in Chrome.
    To answer your questions specifically:
    1.) There was a time before we supported multiple tabs, webcam streaming, H.264 video decoding and modern security sandboxing.  I wouldn't recommend using those versions.
    2.) There are a few posts about this, but we have ~1.5 billion users.  The majority of the very small number of folks relative to our install base are complaining their machines are overheating, which is a symptom of an ineffective cooling system. 
         There's nothing magic about Flash that causes it to somehow superheat the CPU.
         There was a time before tabs, where people didn't normally run 5-50 browser windows.  Websites also got much more complex, and the security threats got far more serious and complex.
         Playing video as a plug-in in the browser as opposed to something like VLC is inherently less efficient, as pretty much each pixel and packet gets passed through the browser before it gets to the OS or drivers.
         All of these things require additional processing.  The resources on your computer are still finite, and there is an upper limit to the number of simultaneous tabs you can use.
         At some point, you come to a juncture where you need to decide between throwing more hardware at the problem, or using less tabs simultaneously.
         Also, most laptops have power saving CPUs, so they'll ratchet the clock speed down to save battery.  You might want to check your power settings to make sure you're running at the CPU's full capacity when plugged in.
    3.) Not that would generate anything really useful.
    4.) Possibly.  You actually already have a multi-core machine.  I think you'd get more bang for your buck by enabling hardware acceleration and switching browsers.
    5.) You already have a multi-core machine that we support.
    Your Wish: We're constantly addressing security issues identified through our own testing, emerging research and intelligence from our partners in academia, government and industry.  We're also looking for opportunities to tune the player, but the reality is that Intel, Nvidia and ATI (and a long list of others, in addition to Adobe) have tuned Flash Player extensively for their hardware.  We work closely with the Internet Explorer and Chrome teams to continue to make the Flash experience better, and are always happy to work with the Firefox team should they decide that they're interested in plug-ins and the desktop browser again.  At the end of the day, Flash is just a low-level runtime.  It's just as possible to write inefficient ActionScript as it is to write inefficient C++, and while we provide some fantastic tooling for profiling your Flash content, it's up to individual content providers to write efficient code.  It's really difficult to find opportunities to make generic optimizations that don't break a percentage of the hundreds of millions of sites published with Flash content.
    I'm actually still not clear on what the problem you're experiencing is.  All software running on your machine that's actively processing something is going to use a non-zero percentage of CPU time.  The symptoms you describe indicate that Flash consumes 5% of the CPU, which is totally reasonable.  I'm guessing that I don't have the complete story.

  • JMS adapter insufficient

    Hi,
    I'm implementing a connection from MQ to SAP, through XI.
    The simple things work, but I do have some problems with the more complex scenario's.
    I think the JMS-adapter isn't sufficient enough for my implementation :
         - performance : a load off messages takes ages => multithreading ?
         - multiple IDoc types:
              I have 4 IDoc types that should be processed in the right order.  If one adapter could read them all, the order would be right,
              but the adapter can't read different sorts of IDocs so I had to split them over 4 queues, in which case the order becomes a problem.
         - when there is a connection problem (network drop or so), the JMS adapter doesn't recover.
    My question is :
         should I go for a java proxy to get the messages from the queue and into XI (in effect write my own JMS-code) ?
         If so, since I've never created a proxy, does anyone have some sample code with an MQ-connection ?
    Regards
    T

    Hi Tom,
    I don't have specific code for proxy.  However, I will explain the steps:-
    ABAP proxies are created in SPROXY transaction.  This is executed on the Application System (not the integration server).  As part of the config of the WAS, an HTTP destination to the IS is maintained in SM59.  This allows the Appl system to retrieve the WSDL desc of the interface as the basis of proxy generation. 
    Use SPROXY transaction on the application system. Right click on your relevant interface and choose Create.  Enter the Prefix and Package to generate unique names.  The system generates methods --> EXECUTE_SYNCHRONOUS and EXECUTE_ASYNCHRONOUS based on the interfaces.  Once you are done with this you can apply your code.
    To generate proxies for java applications, right click on the interface in the IR and choose Java Proxy Generation.  The wizard will get started.  Specify if this is a new proxy or a regenerated proxy (if the interface is changed after a proxy has been generated, you must regenerate and recompile).  Select the software comp version that contains the interfaces.  Select the message interface to use as the basis of proxy generation.  Click Finish to generate the java classes.
    Regards.
    Praveen

  • High Cohesion and a dash of Low coupling

    I have two classes.(well there more but i will use two to explain my problem)
    Items are processed one by one, by class1, as soon as an item is processed it is sent to class2 for futher processing. Class2 contains queues which stores items sent from class1 while they wait to be processed. I have implemented this, however my problem is as follows:
    There is a need for a 'routing system' class which recieves items (one at a time) from class1, works out the shortest queue lenght in class2 and then sends that item to that queue.
    The biggest probelm is that the class must be able to handle different situations. E.g able to handle any number of queues, etc.
    (Some may be thinking why don't you just write this as method inside class2. The answer is that this 'routing system' is going to be used by the whole program, so it must be made available to all classes without the need for)
    Basically High Cohesion and low coupling is the key and this is the reason why I find it difficult to implement this class.
    Can anyone help, Thanks.

    My suggestion would be to put a manager on top of the queue-set.
    So, for a given set of queues, there is a managing-thread that 'receives' the input (output from a prior op) and also responds to the dequeue operation. There are plenty of article on multithreading with multiple producers and multiple consumers. Just use a singleton for the manager.
    http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=Java+Multithreading+multiple+producers
    http://archive.devx.com/sourcebank/details.asp?resourceNum=123662

  • I am looking to use multithreading in order to run multiple tests in parallel on one UUT.

    I am looking to multithread multiple tests in paralllel on one UUT.  I looked in the main site and all examples are on zip files that I seem to not be able to successfully download from the site.  Does anyone have any file examples or white papers on this subject that I can view???
    Solved!
    Go to Solution.

    put one test in a sub sequence.  then call that subsequence using New Thread as the Execution Options:
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • URGENT:Handle multiple connection in a multithreaded server.

    I hava a multithreaded server where it can handle multiple connection.
    The program works in this way. First, it will wait for connection. Once it accepts a connection, it will pass the socket to a thread class which will in turn process the connection. Then, the server will go back to the infinite loop to wait for new connection.
    Since I am not very familiar on using thread, I would like to post the following questions:
    1) Let say that my server can handle multiple connections. This is to cater for the different requests from the client. For instance, the client may make one connection for chatting and another connection for sending file(something like we have in Yahoo Messanger). So, at the server side, how can I differentiate between the connection for CHAT and the connection for SEND FILE so that I can handle the requests separately. It means I can save the file sent from client and display the chat message in the JTextArea?
    2) How can I stop the server, clean up the thread and start the server again for waiting new connection? Currently, I can just start my server once.
    For reference,following are parts of my program:
    public void listenSocket(){
    try{
    server = new ServerSocket(5000);
    } catch(IOException e) {
    System.out.println("Failed to listen on port 5000");
    System.exit(0);
    try{
    while(true){
    server1frame sframe=null;
    ChatHandler handler;
    handler = new ChatHandler(sframe,server.accept(),jTextArea1,jTextField1,jFileChooser1);
    handler.start();
    } catch(IOException e) {
    System.out.println("Accept failed:5000");
    System.exit(0);
    //to close the connection as the final steps before program exit.
    } finally {
    try{
    server.close();
    } catch (IOException ioe) {
    ioe.printStackTrace();
    public void run() {
    out.println("Connection Established");
    out.flush();
    try {
    String line;
         while(!(line =in.readLine()).equalsIgnoreCase("QUIT")) {
    if(line.startsWith("CLIENT"))
    jTextArea1.append("\n"+line);
    else if(line.startsWith("Connecting")) {
    jTextArea1.append("\n"+line);
    else if (line.startsWith("Finish")) {
    JOptionPane.showMessageDialog(sframe,"File has finished downloading",
    "File Download Complete",JOptionPane.INFORMATION_MESSAGE);
    else {
    BufferedWriter fout = new BufferedWriter(
    new FileWriter("e:/num1.txt",true));
    fout.write(line);
    fout.newLine();
    fout.flush(); }
         } catch(IOException ioe) {
         ioe.printStackTrace();
         } finally {
         try {
              in.close();
              socket.close();
         } catch(IOException ioe){
    System.out.println("Fail to close connection.");

    1) Let say that my server can handle multiple
    connections. This is to cater for the different
    requests from the client. For instance, the client may
    make one connection for chatting and another
    connection for sending file(something like we have in
    Yahoo Messanger). So, at the server side, how can I
    differentiate between the connection for CHAT and the
    connection for SEND FILE so that I can handle the
    requests separately. It means I can save the file sent
    from client and display the chat message in the
    JTextArea?Either your server listens on two different ports for two different protocolls, (then you would a server thread for each port) or you accept connections for both protocolls on both ports, and have the client state what protocoll it is using :
    eg:
    accept Connection - start new Thread - read first line - depending on protocoll pass protocoll object (CHAT, FTP) to run method
    There is an example for a simple protocoll at : http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html
    2) How can I stop the server, clean up the thread and
    start the server again for waiting new connection?
    Currently, I can just start my server once.You normally start servers only once. It should then be up and listening for it's entire lifetime. Restarting a server should only be needed if it hangs or crashes.

  • How to comminucate with multiple PLCs with Modbus TCP/IP using dynamic multithreads?

    I have an application in which I communicate with several PLCs using MODBUS TCP/IP toolkit. There is an array of IP addresses that the user can configure. Using for loops allows to work with this however if one PLC is out, the program waits for the timeout before polling the next PLC. I would like to use a multithreading type in order that all PLCs are polled at once and is not dependent of each other. In other words, I would like to dynamically simulate several while loops happening at the same time. Is this possible?
    Thanks
    arikb

    arikb wrote:
    Thanks A_Patel,
    I thought of doing that but do I need to run this as a VI server in that case? How would I pass inputs and outputs of the subvi?
    Appreciate the help,
    arikb
    Take a look at my Nugget on dynamically creating occurences found here.
    Just ignore the Occurence stuff and the rest of the code and verbage should help you. The example code creates a bunch of background processes and passes a unique parameter to each.
    Have fun,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Multiple BDBs in multithread application (C++)

    My problem is follows
    1) Main thread opens 2 BDBs (I am opening with O_CREATE|DB_THREAD flag)
    2) Child threads do Db::get on both the BDBs (Using malloc flag for Db::get to allocate memory)
    3) Some of the calls to Db::get from child threads are raising SEGV
    Can someone please help me.
    The above situation is working fine in non-threaded application.
    Regards,
    Ompraksh Maity

    hello,
    I have some additional information on this topic which hopefully
    will help.
    Db::get() will not work if you set the DB_DBT_MALLOC flag for the key
    as you have in your example. With the DB_DBT_MALLOC flag set on a Dbt,
    the idea is that the get() is first performed, malloc'ed memory is
    allocated and is then filled with the content of the retrieved key or
    data. Based on this, you can set DB_DBT_MALLOC on a data Dbt, but not
    on the key with Db::get().
    The exception to this is the Db::get() call made with the DB_CONSUME
    or DB_CONSUME_WAIT flags; in these cases the key doesn't need to be specified,
    as it will be retrieved from the database (the head of the queue) along
    with the corresponding data. For the other generally used flags (no_flag,
    DB_GET_BOTH, DB_SET_RECNO, DB_MULTIPLE), you have to provide a
    value for the key used in the Db::get() call. When you set the DB_DBT_MALLOC
    flag on the key, it doesn't contain a value since it doesn't point to a memory location,
    it's data and size fields will have to be filled after the Db::get() call.
    If you use a cursor and do a Dbc::get() call, then you can expect the
    call to succeed after having set the DB_DBT_MALLOC flag for both the
    key and data, when you use one of the following flags for the Dbc::get() call:
    DB_CURRENT, DB_FIRST, DB_LAST, DB_NEXT, DB_NEXT_NODUP (if the
    cursor is not yet initialized), DB_PREV, DB_PREV_NODUP (if the cursor is initialized).
    All the other flags for the Dbc::get() call imply that the key Dbt points
    to a valid memory location holding the item that will be searched in
    the database, so in these case you cannot specify DB_DBT_MALLOC for both
    the key and data Dbt's.
    thanks,
    Sandra

  • Video transmission with multithreading. I am having a problem?

    I am doing an application for sending video streams to multiple clients at the same time. So am using multithreading. I have the following codes to do the transmission. When I am using it with one thread only it is working fine. But when I use it with more threads for multiple transmissions I am have an error saying �Unable to realize com.sun.media.ProcessEngine�. Can anyone help me plz.
    import java.awt.*;
    import javax.media.*;
    import javax.media.protocol.*;
    import javax.media.protocol.DataSource;
    import javax.media.format.*;
    import javax.media.control.TrackControl;
    import javax.media.control.QualityControl;
    import java.io.*;
    import java.lang.Thread;
    public class VideoTransmitThread extends Thread{
    // Input MediaLocator
    // Can be a file or http or capture source
    private MediaLocator locator;
    private String ipAddress;
    private String port;
    private Processor processor = null;
    private DataSink rtptransmitter = null;
    private DataSource dataOutput = null;
    public VideoTransmitThread(MediaLocator locator,
                   String ipAddress,
                   String port) {
         this.locator = locator;
         this.ipAddress = ipAddress;
         this.port = port;
    * Starts the transmission. Returns null if transmission started ok.
    * Otherwise it returns a string with the reason why the setup failed.
    //run method for the thread
    public void run( ) {
         String result;
         // Create a processor for the specified media locator
         // and program it to output JPEG/RTP
         result =createProcessor();
         if (result != null)
         System.out.println("error: "+result);
         // Create an RTP session to transmit the output of the
         // processor to the specified IP address and port no.
         result =createTransmitter();
         if (result != null) {
         processor.close();
         processor = null;
         //return result;
         System.out.println("error: "+result);
         System.exit(0);
         try {
         Thread.sleep(1000); // 100 msec
         } catch (InterruptedException e) {
         return;
         // Start the transmission
         processor.start();
    * Stops the transmission if already started
    public void stop1() {
         synchronized (this) {
         if (processor != null) {
              processor.stop();
              processor.close();
              processor = null;
              rtptransmitter.close();
              rtptransmitter = null;
    private String createProcessor() {
         if (locator == null)
         return "Locator is null";
         DataSource ds;
         DataSource clone;
         try {
         ds = Manager.createDataSource(locator);
         } catch (Exception e) {
         return "Couldn't create DataSource";
         // Try to create a processor to handle the input media locator
         try {
         processor = Manager.createProcessor(ds);
         } catch (NoProcessorException npe) {
         return "Couldn't create processor";
         } catch (IOException ioe) {
         return "IOException creating processor";
         // Wait for it to configure
         boolean result = waitForState(processor, Processor.Configured);
         if (result == false)
         return "Couldn't configure processor";
         // Get the tracks from the processor
         TrackControl [] tracks = processor.getTrackControls();
         // Do we have atleast one track?
         if (tracks == null || tracks.length < 1)
         return "Couldn't find tracks in processor";
         boolean programmed = false;
         // Search through the tracks for a video track
         for (int i = 0; i < tracks.length; i++) {
         Format format = tracks.getFormat();
         if ( tracks[i].isEnabled() &&
              format instanceof VideoFormat &&
              !programmed) {
              // Found a video track. Try to program it to output JPEG/RTP
              // Make sure the sizes are multiple of 8's.
              Dimension size = ((VideoFormat)format).getSize();
              float frameRate = ((VideoFormat)format).getFrameRate();
              int w = (size.width % 8 == 0 ? size.width :
                        (int)(size.width / 8) * 8);
              int h = (size.height % 8 == 0 ? size.height :
                        (int)(size.height / 8) * 8);
              VideoFormat jpegFormat = new VideoFormat(VideoFormat.JPEG_RTP,
                                       new Dimension(w, h),
                                       Format.NOT_SPECIFIED,
                                       Format.byteArray,
                                       frameRate);
              tracks[i].setFormat(jpegFormat);
              System.err.println("Video transmitted as:");
              System.err.println(" " + jpegFormat);
              // Assume succesful
              programmed = true;
         } else
              tracks[i].setEnabled(false);
         if (!programmed)
         return "Couldn't find video track";
         // Set the output content descriptor to RAW_RTP
         ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.RAW_RTP);
         processor.setContentDescriptor(cd);
         // Realize the processor. This will internally create a flow
         // graph and attempt to create an output datasource for JPEG/RTP
         // video frames.
         result = waitForState(processor, Controller.Realized);
         if (result == false)
         return "Couldn't realize processor";
         // Set the JPEG quality to .5.
         setJPEGQuality(processor, 0.5f);
         // Get the output data source of the processor
         dataOutput = processor.getDataOutput();
         return null;
    // Creates an RTP transmit data sink. This is the easiest way to create
    // an RTP transmitter. The other way is to use the RTPSessionManager API.
    // Using an RTP session manager gives you more control if you wish to
    // fine tune your transmission and set other parameters.
    private String createTransmitter() {
         // Create a media locator for the RTP data sink.
         // For example:
         // rtp://129.130.131.132:42050/video
         String rtpURL = "rtp://" + ipAddress + ":" + port + "/video";
         MediaLocator outputLocator = new MediaLocator(rtpURL);
         // Create a data sink, open it and start transmission. It will wait
         // for the processor to start sending data. So we need to start the
         // output data source of the processor. We also need to start the
         // processor itself, which is done after this method returns.
         try {
         rtptransmitter = Manager.createDataSink(dataOutput, outputLocator);
         rtptransmitter.open();
         rtptransmitter.start();
         dataOutput.start();
         } catch (MediaException me) {
         return "Couldn't create RTP data sink";
         } catch (IOException ioe) {
         return "Couldn't create RTP data sink";
         return null;
    * Setting the encoding quality to the specified value on the JPEG encoder.
    * 0.5 is a good default.
    void setJPEGQuality(Player p, float val) {
         Control cs[] = p.getControls();
         QualityControl qc = null;
         VideoFormat jpegFmt = new VideoFormat(VideoFormat.JPEG);
         // Loop through the controls to find the Quality control for
         // the JPEG encoder.
         for (int i = 0; i < cs.length; i++) {
         if (cs[i] instanceof QualityControl &&
              cs[i] instanceof Owned) {
              Object owner = ((Owned)cs[i]).getOwner();
              // Check to see if the owner is a Codec.
              // Then check for the output format.
              if (owner instanceof Codec) {
              Format fmts[] = ((Codec)owner).getSupportedOutputFormats(null);
              for (int j = 0; j < fmts.length; j++) {
                   if (fmts[j].matches(jpegFmt)) {
                   qc = (QualityControl)cs[i];
                   qc.setQuality(val);
                   System.err.println("- Setting quality to " +
                             val + " on " + qc);
                   break;
              if (qc != null)
              break;
    * Convenience methods to handle processor's state changes.
    private Integer stateLock = new Integer(0);
    private boolean failed = false;
    Integer getStateLock() {
         return stateLock;
    void setFailed() {
         failed = true;
    private synchronized boolean waitForState(Processor p, int state) {
         p.addControllerListener(new StateListener());
         failed = false;
         // Call the required method on the processor
         if (state == Processor.Configured) {
         p.configure();
         } else if (state == Processor.Realized) {
         p.realize();
         // Wait until we get an event that confirms the
         // success of the method, or a failure event.
         // See StateListener inner class
         while (p.getState() < state && !failed) {
         synchronized (getStateLock()) {
              try {
              getStateLock().wait();
              } catch (InterruptedException ie) {
              return false;
         if (failed)
         return false;
         else
         return true;
    * Inner Classes
    class StateListener implements ControllerListener {
         public void controllerUpdate(ControllerEvent ce) {
         // If there was an error during configure or
         // realize, the processor will be closed
         if (ce instanceof ControllerClosedEvent)
              setFailed();
         // All controller events, send a notification
         // to the waiting thread in waitForState method.
         if (ce instanceof ControllerEvent) {
              synchronized (getStateLock()) {
              getStateLock().notifyAll();
    * Sample Usage for VideoTransmitNew class
    public static void main(String [] args) {
         // We need three parameters to do the transmission
         // For example,
         // java VideoTransmitNew file:/C:/media/test.mov 129.130.131.132 42050
         System.err.println("Start transmission");
         //Create a video transmit object with the specified params.
    MediaLocator URL=new MediaLocator("file:///C:/media/test.mpg");
    //Am using 3 different threads.
         new VideoTransmitThread(URL,"CSELAB12PC10","9876").start();
         new VideoTransmitThread(URL," CSELAB12PC11","9870").start();
         new VideoTransmitThread(URL," CSELAB12PC12","9690").start();
         //close all transmission before quiting.

    Hm, that was my silver bullet. Other than doing an uninsall and then installing Presenter again, you may need to reach out to Adobe and see if they can identify what could be causing this.

  • Data in the table changes when multiple users try to submit data

    I have a dynamic table. The table is created in the wdDoModifyView. The user can load data into the table from an excel file. So I have a "Load" button that loads the data from the selected excel file to the table. I also have a "Submit" button. This "Submit" button converts the data to an xml file and make a call to an oracle stored procedure for validation check. If there's an error it will be returned and displayed to the user. If none, a summary of data for posting will be displayed to the user. If the data is correct and the user hit the ok button, the same data will be return to oracle sp for loading in the table.
    The problem we encountered is when multiple users are loading and submitting at the same time, the data displayed in the dynamic tables changes after clicking the ok button. It is as if, the table displays the data being loaded by other user.
    This is an error that is difficult to recreate. This doesn't happen all the time. I hope you somebody could enlighten me why this is happening. I'm not sure if it has something to do with multithreading or session.
    Edited by: Marlyn Agco on Apr 14, 2009 3:57 PM

    Hi Armin,
    Did you mean storing view instances in static references and accessing them outside the wdDoModifyView is not a good idea? In wdDoInit the nodes are dynamically created according to the xml file being returned by the database. This node is stored in a static variable which is also used in wdDoModifyView to create the dynamic table.
    What do you suggest? We're still encountering same issue when multiple users are uploading data.

  • How to configure ENV and DB for multithreaded application?

    Hi,
    From document, I know DB_THREAD must be checked for both ENV and DB, but , I don't know which one is best choice for multithreaded application while facing DB_INIT_LOCK and DB_INIT_CDB. In my application, there maybe multi readers and writers at the same time, should I use DB_INIT_LOCK instead of DB_INIT_CDB? what other flags should I use?
    DB_INIT_CDB provides multiple reader/single writer access while DB_INIT_LOCK should be used when multiple processes or threads are going to be reading and writing a Berkeley DB database.
    Thanks for your seggestions and answers.

    Thanks for the explanation,
    The Berkeley DB Concurrent Data Store product
    allows for multiple reader/single writer access
    to a database. This means that at any point in time,
    there may be either multiple readers accessing a
    database or a single writer updating the database.
    Berkeley DB Concurrent Data Store is intended for
    applications that need support for concurrent updates
    to a database that is largely used for reading.
    If you are looking to support multiple readers and
    multiple writers then take a look at the Transactional
    Data Store product
    (http://download.oracle.com/docs/cd/E17076_02/html/programmer_reference/transapp.html)
    In this case the Environment is typically opened with:
    DB_INIT_MPOOL, DB_INIT_LOCK, DB_INIT_LOG, and DB_INIT_TXN.
    Let me know if I missed any of your question.
    Thanks,
    Sandra

  • Multiple instances of FileOutputStream

    Hi, I'm learning how to use Java's multithreading features. I created a class called "ObjectMaker". An instance of this class serializes some objects into a file, using a FileOutputStream (inside an ObjectOutputStream) for writing. In the mean time an other object of another class deserializes those objects reading from the file. Each concurrent access to the file (for writing,reading) is synchronized. Here's the problem:[ u]if each writer has its own FileOutputStream, then the concurrent writing on the file doesn't work (despite of every writer is synchronized on the same object), and the reader aren't able to read anything from the file; if the FileOutputStream is static (every instance share the same FileOutputStream reference) everything works. I read on Documentation that some OS "allow a file to be opened for writing by only one FileOutputStream (or other file-writing object) at a time" .But it also says that I would recive an exception from FileOutputStream if I try to open a file for writing that is already open by another FileOutputStream....and It doesn't happen, no exception are thrown.Then here is the problem:It's possible to manage Multiple instances of FileOutputStream linked on the same file?

    Hello Joseph,
    Have u been successful on the installation.
    There were no replies after yours.
    Can you please let me know about installing 2 MDS instances on the same host.
    If you have any document you followed please mail me to [email protected]
    It will be more helpful as the dead line to this is killing me.
    Regards,
    VishnuM

  • Does Adobe Flex 4.6 SDK supports multithreading?

    Hi,
    As we are using Adobe Flex 4.6 sdk for our vmware vcenter plug-in development. we need to handle the situations like updating the data in multiple panels and portlets of a dashboard simultaneously.
    So we are thinking to implement this using multithreading concept.
    I am hearing flex doesn't support multi-threading, some workers constructors will give flavor of the multi-threading in flex.
    It will be helpful if you provide some information about
    1. Does Adobe Flex 4.6 SDK supports multithreading? If so how to implement?
    2. How to use Workers in flex and what are the limitations?
    Thanks and Regards,
    Sravan Kumar.

    https://forums.adobe.com/message/4562551

Maybe you are looking for

  • REPORT GENERATION TOOLKIT AND EXCEL

    i have a problem with report generation toolkit and excel the problem is: i must read & write from a excel worksheet when this is open but when i using the report generation the worksheet is open another time have some solution for this problem? sorr

  • Trial Balance report  For FI

    If any one have trial balance report for FI pls send me..

  • How to call function created in another schema...

    I am trying as follows... user1 has one function named 'function1' Now I am granting execute privilege to user2 as ... GRANT EXECUTE ON function1 TO USER2 ; But when I run the function from user2 I am getting following error... declare aa varchar2(10

  • In Mac's PAINTR application, what exactly does the "Splash" function do?

    n Mac's PAINTR application, what exactly does the "Splash" function do?

  • Course manager iTunesU error

    I created an iTunesU account in the Course Manager as an independent instructor (my college does not have an iTunesU account). I can log in to course manager but the only  thing I can see is the Instructor Info page, my institution has been cleared,