How can i regulate thread timing?

in my Server/Client app, Server periodically sends an Object thru an ObjectOutputStream dn Client constantly listend for an ObjectInputStream. how can i prevent an ObjectInputStream to be created before an ObjectOutputStream is created to prevent a StreamCorruptedException? thanks

yes they are. well here is the more detailed thread: http://forum.java.sun.com/thread.jspa?threadID=632037&tstart=15
in a nutshell: Client is a Thread that sleeps and wakes up every 5 seconds to send "req" string. ServerClient receives the "req" and performs the necessary operations. in this case, its supposed to create an ObjectOutputStream and Client will receieve it using ObjectInputStream. this cycle sometimes goes on for 3 times, 5 times, 8 times, 15 times, or watever, its random. then it blows up and i get a StreamCorruptedException. I googled some stuff and read that it may be because an ObjectInputStream is created before an ObjectOutputStream. thats why i was asking if i can regulate this cycle thru some kind of timing.... or something.. i dunno i dont really understand the problem...

Similar Messages

  • How can I set the timing property node to sample clock property

    I am developing a code for acquiring acceleration data from cDAQ 9184 using DAQmx VIs. I need to include a timing property node with a (sample clock rate) reading property. How can I do that?
    Solved!
    Go to Solution.

    I really appreciate your effort. NowI have this property Node '' DAQmx Timing'' on the block diagram but the problem is that when click on the property NO menu shows up there. I dont know were the problem is. Is there any software drive I need to install other than DAQ mx to solve this problem? The same problem happent any time I want to use a property node. Let me send you my code file so that you can see where the problem is. And I really thank you in advance for your support.
    Attachments:
    acceleratiom programing code with logging and Analog Triggering.vi ‏22 KB

  • How can I have threads communicate with each other?

    I'm working on a project that requires a group of classes communicating with each other. I decided on using a server and carrying out communication that way. However, my app only has communication between the client and server. I need the clients to be able to communicate with each other. Does anyone know how I can do this or point me to a good tutorial?

    Sorry, here's a bone stock example of my server and client:
    <SERVER>
    package testserver;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class TestServer
    static int portOpen;
    public static void main(String[] args)
    portOpen=4000;
    try
    ServerSocket portListener = new ServerSocket(portOpen);
    TestServer userThreads = new TestServer();
    while (1==1)
    Socket userConnection=portListener.accept();
    userThreads.new PortConnection(userConnection);
    catch (Exception e)
    System.out.println("The server encountered a serious error. Server shut down.");
    e.printStackTrace();
    System.exit(0);
    class PortConnection extends Thread
    //Declare variables to handle connections.
    Socket ourConnection;
    BufferedReader serverInput;
    PrintWriter serverOutput;
    PortConnection(Socket userConnection)
    try
    ourConnection=userConnection;
    serverInput=new BufferedReader(new InputStreamReader(userConnection.getInputStream()));
    serverOutput=new PrintWriter(userConnection.getOutputStream(),true);
    start();
    catch (Exception e)
    System.out.println("An error occurred when a user attempted a connection.");
    public void run()
    serverOutput.println("Welcome to the Server.");
    try
    serverOutput.close();
    serverInput.close();
    ourConnection.close();
    catch (Exception e)
    </SERVER>
    <CLIENT>
    package testclient;
    import java.io.*;
    import java.util.*;
    import java.net.*;
    public class TestClient {
    static BufferedReader userInput;
    static Socket quizServer;
    static BufferedReader serverInput;
    static PrintWriter serverOutput;
    static String serverData;
    public static void main(String[] args) {
    userInput = new BufferedReader(new InputStreamReader(System.in));
    try {
    quizServer=new Socket("localhost",4000);
    catch (Exception e) {}
    try
    serverInput=new BufferedReader(new InputStreamReader(quizServer.getInputStream()));
    serverOutput=new PrintWriter(quizServer.getOutputStream(),true);
    catch (Exception e) {}
    try {
    serverData=serverInput.readLine();
    catch (Exception e) {}
    System.out.println(serverData);
    </CLIENT>

  • How can I put a timed pause between CFMAIL sendouts?

    A preface, this is not marketing e-mailing I'm discussing, it's already opted-in government notifications requested by the customers.
    This is driving me absolutely crazy.  I've got a working SQL query that pulls a number or records (e-mail addresses), then sends out a series of mailings in batches (still working on that part).
    What I'm stuck on is how in the world can I pause the CFMAIL processings between batches?  For example, I want to send 500 e-mails, pause for 10 minutes, send the next 500, etc.
    CFTHREAD looks kinda like what I might need but I'm not sure.
    We're afraid of sending all at once (probably no more than 5,000 to 10,000 total) in fear of being blacklisted.  Usually this app will only send 100 to 500 at a time.
    Thanks in advance for any help you guys can give!
    This is for CF8, incidentally.
    T

    I've developed a mailing application like this for our own (used for sending up to 100k emails per job so far without a problem) and my solution was this (simplified):
    1) set-up a CFusion cronjob that runs every X minutes and executes the following
    2) select all records/email-addresses within the sql query (no maxrows parameter)
    3) cfloop over this query result-set with startrow and endrow parameter to select just the desired number of addresses
    4) stored endrow value in database and used this one as startrow param for the next run/loop, X minutes later... and so on
    I do not think that using cfsleep is wise, as such mailingjobs could potientially run for hours if not days, and you don't want to let scripts run this long.
    First they occupy one of the precious "max parallel cf threads" slots on your server and second you could potentially loose all progress of this task if your server ever restarts while this script is running.

  • How can I stop a timed loop in the middle of its cycle?

    Hello all,
    I'm creating VI that will gather data from a series of thermocouples and outputing that data to a graph as well as to a spreadsheet file.
    The sampling rate for each channel needs to be independent and variable. That is, they want to increase the sampling rate to 1/sec during temperature transitions, and then 1/10minutes (for example) when saturated.
    I was going to use a menu ring for the user to select the sampling rate (1 second to 15 minutes, with 7 different rates in between) and then, using a case statement, select the value of how long the 'wait (ms)' should wait in each loop.
    This kind of works with one major problem. If the user currently has the sampling rate set to 15 minutes, th
    en wants to switch it to 1 second, it can take up to 14:59 for the 'wait(ms)' to finish waiting on the 15 minute wait before it switches to the faster sampling rate.
    Is there a way to stop a 'wait(ms)' in the middle of its wait cycle? Or is there a better way of doing this?
    Thanks in advance for your help.
    Dave Neumann
    [email protected]

    "Neumannium" wrote in message
    news:[email protected]..
    > Hello all,
    >
    > I'm creating VI that will gather data from a series of thermocouples
    > and outputing that data to a graph as well as to a spreadsheet file.
    >
    > The sampling rate for each channel needs to be independent and
    > variable. That is, they want to increase the sampling rate to 1/sec
    > during temperature transitions, and then 1/10minutes (for example)
    > when saturated.
    >
    > I was going to use a menu ring for the user to select the sampling
    > rate (1 second to 15 minutes, with 7 different rates in between) and
    > then, using a case statement, select the value of how long the 'wait
    > (ms)' should wait in each loop.
    >
    > This kind of works with one maj
    or problem. If the user currently has
    > the sampling rate set to 15 minutes, then wants to switch it to 1
    > second, it can take up to 14:59 for the 'wait(ms)' to finish waiting
    > on the 15 minute wait before it switches to the faster sampling rate.
    >
    > Is there a way to stop a 'wait(ms)' in the middle of its wait cycle?
    > Or is there a better way of doing this?
    Instead of using the wait ms.vi you could use 'tick count' at the beginning
    of the loop and then have an inner loop that keeps checking the 'tick count'
    until time minus time > time to wait.
    You will need to figure out how to handle the case where the millisecond
    timer wraps from 2^32-1 to zero. That should not be too difficult.

  • How can you increase slideshow timing in photos for ipad?

    I want to change the timing of slide change in slideshow, photos for ipad 2. How do I do it?

    Have tried changing timing in settings to 20 sec. When showing photos through Apple TV slideshow in Ken Burns effect, transition occurs every 3 sec. Want to extend this timing.

  • How can I improve the timing of my 2 Digital Output signals?

    Hi,
    I am using a NI DAQ Pad-6015 (usb) with Labview 8.5 and XP, to generate 2 Digital Ouputs (500ms high for the first one and  600ms high for the second one). The timing doesn't need to be very accurate so I am not using the 2 hardware clocks outputs. When runing the VI, and measuring the duration of the outputs with an oscilloscope, I get 520ms and 640ms. This is not too much of a problem, but I would still like to know, if I am doing the right thing in my program, and/or if it is possible de improve it?
    Thanks for your help,
    Regards,
    Marc
    Solved!
    Go to Solution.
    Attachments:
    Forum.vi ‏37 KB

    This VI can be convert to labview 8.0 because subvi are not compatible with old version.
    I post a screenshot.
    Aurélien J.
    National Instruments France
    #adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
    >> Du 30 juin au 25 août, embarquez pour 2 mois de vidéo-t'chat ! Prenez place pour un voyage au coe...
    Attachments:
    image.jpg ‏38 KB

  • How can I regulate the x-/y- scale of the WaveformGraph?

    In my program I indicate different signals after a certain time with the WaveformGraph. Is there a solution to give the WaveformGraph Values, which change automatically with the suitable signals.
    AutoScale isn't suitable.
    Thanks for help!

    Hi happy student,
    If I understand your question correctly, you'd like to programmatically change the scaling of your graph.
    If this is indeed what you're planning to do, there is an easy solution to this. You can use a Property node for the graph, which you can create by right-clicking the graph terminal on your block diagram and selecting 'Property node' from the Create menu. With this property node, you can programmatically change the features for your graph, including the scaling. Just play a bit with it, it's extremely versatile.
    Best,
    Joost van Mameren

  • How Can I Regulate Internet Speed Thru The Router

    I have a E3000 router and I want to slow the upload and download speed to my Xbox is there any way to do this thru the router settings. I have internet that is about 20-30mbps down and 2-3mbps up I want to slow it to about 5-6mbps down and 1-2 mbps up.

    You can set the priority level of your Xbox. Here are the steps:
    Open the web interface,
    Go the Applications and Gaming> QoS
    Enable Internet Access Priority, under Category select Ethernet(for wired) or MAC add (if it's wireless)
    Set your preferred priority level.
    Setting up QoS on a Linksys Wireless-N router

  • How can I restore my sons itouch to original settings without doing the restore through iTunes? He can't remember his passcode and when I try to restore through iTunes it never completes the update/restore without timing out?!?!

    HOw can I restore my sons itouch to original settings without going through iTunes restore? When I plug into iTunes it will never complete the update/restore without timing out? He can't remember his password. I can't get my iTunes to update to the newest level either without timing out. Please help!

    The thread title differs from the original post, sorry for the confusion.  I read password instead of passcode.
    The only way past a passcode lock is by entering the passcode.  Refer to HT1212 iOS: Wrong passcode results in red disabled screen:
    If you cannot remember the passcode, you will need to restore your device using the computer with which you last synced it. This allows you to reset your passcode and resync the data from the device (or restore from a backup).
    If you restore on a different computer that was never synced with the device, you will be able to unlock the device for use and remove the passcode, but your data will not be present.
    As for timing out during the restore...
    If there isn't any antivirus or firewalls in the way, I would try restoring from a different user account or even a different computer.  If still unable to restore without timing out, I would try a different network.

  • How can I implement This? - Via Multiple Threads

    Hi Friends,
    I m getting a list of 4000 emails in an ArrayList. Now I want to put 300 addresses in a mail at a time, and Want to create a new Thread and Send a Mail.
    I want to run 20 threads at a time to do so, Means Each thread is taking 300 addresses from array assigning it to Message and send it. After Sending it should return to ThreadPool.
    Also the 300 addresses should be removed from arraylist.
    Here are code snippet, i m using..
    MailBean.java - A bean which have all the MailProperty and Send Method.
    MailSender.java - It implements Runnable Interface, In its constructor A MailBean Object is Created and in run method it is sending the Mail.
    FileReader.java - It extends ArrayList, it takes a fileName, parse the Emails add email.
    Main.java - Here i want to send mails using ExecutorService class of java.util.concurrent.
    Mailer.java (Main Class)
    public class Mailer {     
         private final FileReader toEmails;
         private ArrayCollection<String> emails ;
         public Mailer(String addressFile){          
              toEmails = new FileCollection(addressFile);
              emails = new ArrayCollection<String>();
                          Here I want to read the 300 emails from toEmails append it in a String and add it to emails ArrayCollection.
        public static void main(String[] args) {
            try{
                 BlockingQueue<Runnable> queue = new ArrayBlockingQueue<Runnable>(200);
                 Executor e = new ThreadPoolExecutor(50, 50, 1, TimeUnit.SECONDS, queue);
                    if (args.length != 1) {
                         System.err.println("Usage: java ExecutorExample address_file" );
                         System.exit(1);
                  Mailer mailer = new Mailer(args[0]);
                  MailBean bean = new MailBean();
                  bean.setSubject("Mail Bean Test");
                  bean.setMessage("Hi This is a Test Message, Please Ignore this Message");
               /*  I want to run the send mails to all the emails (300 emails per String.) with the Exceutor.
                   Can somebody tell, I want a new object of MailSender for each mail
                   and sendmails
                 System.out.println("Creating workers");
                 for(int i = 0; i < 20; i++)
                     e.execute(new MailSender(bean));
                 System.out.println("Done creating workers");
            }catch(Exception ex){
                 ex.printStackTrace();
    } Can Somebody give me hint, How can we do it?

    The problem is the sound buffer. You may stop the method which dispatch the notes to be played... but not clear your sound card buffer....
    anyway: you should implement it in daemon threads. This way you can control the thread suspend, stop, restart, etc.
    use Thread.sleep(milliseconds);

  • How can I use a Selector in a thread safe way?

    Hello,
    I'm using a server socket with a java.nio.channels.Selector contemporarily by 3 different threads (this number may change in the future).
    From the javadoc: Selectors are themselves safe for use by multiple concurrent threads; their key sets, however, are not.
    Following this advise, I wrote code in this way:
             List keys = new LinkedList(); //private key list for each thread
             while (true) {
              keys.clear();
              synchronized(selector) {
                  int num = selector.select();
                  if (num == 0)
                   continue;
                  Set selectedKeys = selector.selectedKeys();
                  //I expected this code to produce disjoint key sets on each thread...
                  keys.addAll(selectedKeys);
                  selectedKeys.clear();
              Iterator it = keys.iterator();
              while (it.hasNext()) {
                  SelectionKey key = (SelectionKey) it.next();
                  if ((key.readyOps() & SelectionKey.OP_ACCEPT) == SelectionKey.OP_ACCEPT) {
                   Socket s = serverSocket.accept();
                   SocketChannel sc = s.getChannel();
                   sc.configureBlocking( false );
                   sc.register( selector, SelectionKey.OP_READ );
                  } else if ((key.readyOps() & SelectionKey.OP_READ) == SelectionKey.OP_READ) {
    //.....Unfortunately synchronizing on the selector didn't have the effect I expected. When another thread select()s, it sees the same key list as the other thread that select()ed previously. When control arrives to serverSocket.accept(), one thread goes ahead and the other two catch an IllegalBlockingModeException.
    I'm not willing to handle this exception, the right thing to do is giving disjoint key sets to each thread. How can I achieve this goal?
    Thanks in advance

    A single thread won't be enough cause after reading data from the socket I do some processing on it that may take long.So despatch that processing to a separate thread.
    Most of this processing is I/O boundI/O bound on the socket? or something else? If it's I/O bound on the socket that's even more of a reason to use a single thread.
    Anyway I think I'll use a single thread with the selector, put incoming data in a queue and let other 2 or 3 threads read from it.Precisely. Ditto outbound data.
    Thanks for your replies. But I'm still curious: why is a selector thread safe if it can't be used with multiple threads because of it's semantics?It can, but there are synchronization issues to overcome (with Selector.wakeup()), and generally the cost of solving these is much higher than the cost of a single-threaded selector solution with worker threads for the application processing.

  • I get two message threads for one contact. One for sms and one for iMessage since I updated to iOS 7. How can I get them both into one thread?

    Ever since I upgraded to iOS7 just two of my contacts I get two message threads for them. One containing their iMessages to me and the other with just regular sms messages. In Contacs, their email and phone number are saved under one name. How can I get the iMessages and sms to come through under one thread in my messaging app again?

    I am having this trouble also, my partner creates a new message to send to me, or sends a picture and it always comes through as an MMS and not using iMessage ...
    will try deleting everything and starting again!

  • How can I have the most recent message in a thread shown first and not last

    Thunderbird (used in conjunction with Gmail - I believe the term is mail client) message threads commence with the oldest; how can I make Thunderbird messages commence with the latest message?

    How do I get around this?
    '''Workaround:'''
    Right Click on the first email in thread and choose:
    'open message in Conversation'
    This open in a new tab and will include all emails both received and sent by you in that conversation.
    It will appear just like the oiginal view with oldest on top.
    Then click on the thread icon to remove the 'threaded' view.
    in my case the list is then sorted by Date with newest on top. So easily identifying the newest email.
    But if required you could clickon Date column header.
    Additional:
    Note: If the new email in the thread is unread:
    View > Threads > Threads with unread
    This will produce a list of the received emails in the thread
    If you then remove the threaded view by clicking on the thread column header, it will list emails by Date in whatever order you desire.
    Unfortunately, this only works with an unread email, so once you have read that email you cannot easily do this again to locate the email in the conversation unless you use the Workaround previously described.

  • How can I debug a sequence that has a subsequence is running in a separate thread?

    Hi,
    How can I debug a sequence that has a subsequence is running in a separate thread?
    I have to have a continues check for a  digital in signal to be able to terminate the sequence if a physical button is pushed.
    This is running in a separate thread, but this way I cannot debug the main sequence.
    Is there any workaround for this?
    Thanks,
    Andras

    This KB might help you:
    http://digital.ni.com/public.nsf/websearch/46D1E157756C37E686256CED0075E156?OpenDocument
    Let me know if this does not help.
    Allen P.
    NI

Maybe you are looking for

  • Adobe Photoshop CS5.1 - Mac OS 10.7.5 - Filter Gallery background is black

    The background colour of the Filter Gallery window (and any filter window) is black. I can see sliders and checkboxes, but I cannot see the related labels and text. This does not happen in the Adobe Illustrator Effects windows. I've rebuilt PS settin

  • 1 item could not be synced. See iTunes for more information

    After syncing  my iphone 4 ios 5 with itunes the following message appears ''1 item could not be synced. See iTunes for more information''. Everything seems to be synced however is there a way to find any information that itunes could not sync?

  • UK USB power adaptor not Charging

    I bought an iPhone 3G last week from the O2 shop - I have tried the UK 3 pin plug in charger with the phone - but it does not charge, cable supplied works when plugs into USB on my Macs. I have tried the adaptor with my 5Gen ipod, still no charge. Is

  • Photoshop CS 6 - can't "SAVE AS"

    When I hit "Save As" - nothing happens ap all...no error message - NOTHING I've checked my mode, resolution, using hte shortcut doesn't do anything either. HELP!

  • Custom Logo in Plus 10.1.2 Worksheet Title

    We can add a custom logo to a worksheet title using Discoverer Desktop. However, this logo is NOT visible in Plus and there is no option to add a new logo to a workbook title. Anyone know how we can add a custom logo to the workbook title in Plus???