Multithreads and InetAddress

My goal is to find out what ip addresses are reachable. I want to find out all ip address 192.168.1.1 ~ 192.168.1.255
The timeout for each ip address is 2 seconds.
In order to speed up the code I decided to execute each query in its own thread. That way it will only be 2 seconds to find out if all of them are reachable or not.
I believe it is checking the 192.168.1.1 address correct. It prints out as -64 which is the two's complement. As you can see from the output below it prints out the results of the first one five times instead of all of them.
Help please.
import java.net.InetAddress;
* @author name
public class IpValidationImpl extends Thread {
    byte[] ipAddr;
    boolean validAddress;
    public IpValidationImpl(byte[] ip){
        ipAddr = ip;
        //System.out.println ((int)ip[0]);
    public void run(){
        int myTimeout = 2000;
        //byte[] address = { 127, 0, 0, 1 };
        try {
            InetAddress addr = InetAddress.getByAddress(ipAddr);
            validAddress = (addr.isReachable( myTimeout ));
            if (validAddress)
                System.out.println ("Good: " + (int)ipAddr[0] + "." + (int)ipAddr[1] + "." + (int)ipAddr[2]+ "." + (int)ipAddr[3]);
        catch (Exception e){
            System.err.println("Error " + e);
    //public boolean isValid(){
      /// if (ip.get(i).isReachable(2000))
         //      System.out.println("Ip: " + i);
          // else
            //   System.out.println("No Ip: " + i);
}and this next part is part of my class.
private void jButtonFindIpActionPerformed(java.awt.event.ActionEvent evt) {                                             
       byte[] address = { (byte)192, (byte)168, 1, 1 };
       byte[] ada = { 127, 0, 0, 1 };
       byte[] abc = { 127, 0, 0, 1 };
       List<IpValidationImpl> ip = new ArrayList<IpValidationImpl>();
       int j;
       for (int i = 0; i < 5; i++){
          j = i + 1;
           abc[3] = (byte)j;
           ip.add(new IpValidationImpl(address));
           ip.get(i).start();
}output:
Good: -64.-88.1.1
Good: -64.-88.1.1
Good: -64.-88.1.1
Good: -64.-88.1.1
Good: -64.-88.1.1
Edited by: inspiron630 on Mar 23, 2009 10:34 PM
Edited by: inspiron630 on Mar 23, 2009 10:36 PM

awesome! last question.
for some reason its not finding 192.168.1.5. I can successfully ping it but the program doesn't find it. It finds all other ip address on the network though, 192.168.1.1 and 192.168.1.4 and 192.168.1.6.
is there more that is required for .isReachable then just ping able to ping the address?
private void jButtonFindIpActionPerformed(java.awt.event.ActionEvent evt) {                                             
       List<IpValidationImpl> ip = new ArrayList<IpValidationImpl>();
       int j = 1;
       for (int i = 0; i < 255; i++, j++){
           byte[] address = { (byte)192, (byte)168, 1, (byte)j };
           ip.add(new IpValidationImpl(address));
           ip.get(i).start();
import java.net.InetAddress;
* @author name
public class IpValidationImpl extends Thread {
    byte[] ipAddr;
    boolean validAddress;
    public IpValidationImpl(byte[] ip){
        ipAddr = ip;
        //System.out.println ((int)ip[0]);
    public void run(){
        int myTimeout = 2000;
        //byte[] address = { 127, 0, 0, 1 };
        try {
            InetAddress addr = InetAddress.getByAddress(ipAddr);
            validAddress = (addr.isReachable( myTimeout ));
            if (validAddress)
                System.out.println (InetAddress.getByAddress(ipAddr).getHostAddress() );
        catch (Exception e){
            System.err.println("Error " + e);
    //public boolean isValid(){
      /// if (ip.get(i).isReachable(2000))
         //      System.out.println("Ip: " + i);
          // else
            //   System.out.println("No Ip: " + i);
}

Similar Messages

  • Multithreading and stored procedures

    Hi,
    Does anyone know of any problems with calling a stored procedure that returns a reference cursor in a multithreading application? In other words, if I have multiple threads calling the same stored procedure is the reference cursor guarenteed to be unique to each thread/thread safe?
    Thanks in advance,
    Glenn

    That should work fine and each call will get a separate ref cursor as long as the app is written properly and is managing it's threads anbd handles properly. Are you seeing some behaviour that suggests this is not the case?
    Chris

  • Multithreading and ttclasses

    Being a newcomer to TT, I would like to know if:
    Do the client libraries (such as ttclasses) support multithreaded clients (pthreads)? I did not see anything in the docs.
    If it is supported, is there anything at all special that has to be followed and are there any restrictions?

    Yes, all TimesTen APIs are thread safe. In general you will need to link your application with the relevant platform threading library (e.g, libpthread.so). For best results you should code your application to avoid sharing database connections between different threads in an arbitrary fashion. Either use one connection per thread or use a propoerly implemented connection pool. Sharing connections between threads in any other way can make code hard to underdstand and debug and can give rise to unexpected (though not incorrect) behaviours.
    Chris

  • Multithreading and daq acquisition

    I�m trying to run 2 DAQ�s (PCI MIO 16 XE) devices in one PC (Win XP) to acquire N-data samples from 5 AI channels each using LV 7.0. For the acquisition to starts, each device is independently triggered (5KS/s) . It works fine and I can get the data. The problem is that the second DAQ starts the acquisition probably only after the first has finished its acquisition. (I cannot be sure about that because actually I do not know how to get the start time of an acquisition). At least the DAQ�s are starting the acquisition at different times and this could be a problem if the time difference is to big( >500 micro seconds).
    1. is this a classical Multithreading problem? Is there a solution?
    2. how can I assure that both DAQ�s start
    the acq. nearly at the same time?
    3. how can I get the start time of the Acq. ?
    4. if I have to use 4 DAQ�s on one PC will this work? Known problems?
    Thanks
    Alberto

    Let me try to explain my problem using the DAQmx example VI �Cont Acq&Graph Voltage-Ext Clk- Dig Start.vi�.
    Making few changes to the above VI, you can use it as a Sub-Vi. ( I also limited the number of scans to 1000). I used 2 PCI MIO 16XE-10 devices and wrote a program using two of this sub.vi. I used one trigger signal and one clock for both devices and scanned the same channel. As input I used a Sinus voltage. After the program runs, If I plot the obtained data time independent, i.e the x-axis is now the scan number rather than time (relative or absolute) I get a shift in the signals of about 90 clocks, this means that for example, the scan position for the max amplitude came for one device 90 clocks later than for th
    e first device. This is unacceptable for my application
    In other test , If I just did copy the block diagram of the example in a new VI twice and made the necessary changes (trigger channel, channel names, etc). Now I got NO shift in the Graph. Both sinus waves were exactly the same. But I still have no idea about the difference on the start time of both devices. I suppose, in this case both devices started at the same time. But how can I be sure of that?
    Without the possibility of using that Sub-Vi�s and because I have to use 1, 2 or 4 devices selectively, my program will be looking very complicated. I�m sure there must be a better way to solve this.
    Thanks

  • CS4 Clone Tool NOT Multithreading and CS4 Slow on i7 965 Processor

    I noticed for the first time that the new clone tool in CS4 is not using all of my processors on my new i7 965XE processor. In fact it uses only one processor and this makes it run incredibly slow. I have also noticed that CS4 in general is rather sluggish on this hardware which is supposedly one of the most powerful processors available. I am running the i7 965XE with 8GB of Ram and still find Photoshop rather slow. I would expect it to be super snappy on this hardware, perhaps I need to optimise settings somehow, does anyone have any suggestions or is CS4 not equipped to properly address the i7 processors yet???
    Any help appreciated.
    My version of CS4 is 11.0

    Mike, could you take a moment to reread your original post?
    "CS4 Clone Tool NOT Multithreading"
    "In fact it uses only one processor and this makes it run incredibly slow."
    Those are not observations and represent two direct conclusions, both of which are incorrect. The first conclusion is that the clone tool is not threaded for multiple processors (it is). The second conclusion is that the lack of threading is what makes the clone tool run slow on your system (almost certainly not the case).
    Implied in your statements is a third conclusion: that using more processors makes things faster (rarely true). That is a common enough fallacy that I felt the need to offer a more detailed explanation to help you and other readers understand more about the issues involved. I tried to keep that explanation short and simple.
    I gave you an alternate hypothesis (small clone area) that could have explained your observation, since you didn't provide enough details for us to rule that out.
    I also gave you more information about what is going on under the hood to help you understand why you observed what you did on processor usage.
    Then I pointed you to existing topics that offer a much more likely explanation for the slowdown you are seeing.
    If you had described with the clone tool slowdown without the incorrect conclusions and without phrasing most of your post as accusations, you probably would have gotten useful help from other users more quickly. Even my first instinct was to ignore your post, but it sounded like you were confused, a bit angry, and needed some help.
    I am sorry you read things into my post that I did not intend. I'm simply trying to help you understand what you observed, and find a solution to the problem you described.

  • Multithread and join

    public class MyTest
         public static void main(String[] args) throws IOException
         {  System.out.println("starting main thread");
              new SimpleThread("Jamaica").start();
            new SimpleThread("Fiji").start();
              join(); // process main thread when all multithread finised. whats the correct syntax ?
               System.out.println("ending main thread");
    class SimpleThread extends Thread {
                 public SimpleThread(String str) {
                     super(str);
                 public void run() {
                     for (int i = 0; i < 10; i++) {
                         System.out.println(i + " " + getName());
                         try {
                             sleep((int)(Math.random() * 1000));
                         } catch (InterruptedException e) {}
                     System.out.println("DONE! " + getName());
             }of course, this code will not work. but i want to do something like that . can i make it working ?

    no, this way it can not work. now, first thread is finishing first . after that, second thread is finished and at last the main thread is finished.
    i did not want this.
    i wanted first and second thread should do as they do but when both of them are done , they should print
    System.out.println("ending main thread");
    can not join() do this ?
    test code :
    import java.io.*;
    public class MyTest
         public static void main(String[] args) throws Exception
         {  System.out.println("starting main thread");
              //new SimpleThread("Jamaica").start();
            //new SimpleThread("Fiji").start();
              SimpleThread t[]=new SimpleThread[3];
              for (int i = 0;i<2; i++) {
                             t=new SimpleThread(i+"");
                             t[i].start();
                             t[i].join();
              // process main thread when all multithread finised. whats the correct syntax ?
              System.out.println("ending main thread");
    class SimpleThread extends Thread {
    public SimpleThread(String str) {
    super(str);
    public void run() {
    for (int i = 0; i < 10; i++) {
    System.out.println(i + " " + getName());
    try {
    sleep((int)(Math.random() * 1000));
    } catch (InterruptedException e) {}
    System.out.println("DONE! " + getName());

  • Multithread and multilanguage

    i give support to a db where run web application. this db is configured in multithead mode. now the business needs a multilanguage characteristic. the development team want use a "alter session ... nls" statement for each request. i am in an doubt if it is the better way to do this.
    thanks

    It depends on what functionality is to become localized. If ORA-xxxx error messages have to be shown in multiple languages that using ALTER SESSION as part of each call is reasonable. But if sorting or date formatting is to be localized, you may chose to specify the NLS parameters directly in affected NLSSORT and TO_CHAR calls.
    Of course, you may design a sharing scheme, where DB sessions are shared (multithreaded) among web sessions only if the web sessions' NLS environment matches.
    As ALTER SESSION should be a relatively cheap operation it may be not worth implementing any optimization. You could run a benchmark to find out if adding ALTER SESSION adds any significant overhead.
    -- Sergiusz

  • MultiThreads and java.io.InterruptedIOException, Plz. help

    Dear javas,
    I have a multithreaded application, where I'm using wait and notify to make my thread communications, I'm using the java.io.File to get a list of files in the local folder, then read all these files and use the content of the files as my input, my problem is some time a java.io.InterruptedIOException is throwen, and I don't know why?
    it is thrown when I'm trying to read the content of the file, I browsed the Net for more than three days, and no bugs are reported or one have reported any thing.
    did I miss something??
    Bye the way, the problem happen on unix just, and not with windows
    also it happen with my code and with log4j package
    did any one have an idea or can help me?
    I ahve to deliver the project in the next comming day, and I'm stuck with this thing.
    I did find a work around with my code, but I can't do any thing with log4j
    I appreciate your help.

    did you read the exception description? obviously the thread reading the data was terminated too early. there could be an architectural problem with your design, e.g. the reader thread is a daemon thread and the main thread terminates without waiting for all tasks to be terminated.
    robert

  • Multithreading and partitioned shared memory

    Hi All,
    I'm having no success with this (simple?) multithreading problem on my core-i7 processor, using CVI 9.0 (32-bit compiler).
    In the code snippets below, I have a node level structure of 5 integers, and I use 32 calls to calloc() to allocate space for 32 blocks of 128*128 (16K) nodes and store the returned pointers in an array as a global var. 
    Node size in bytes = 20, block size in bytes = (approx) 328KB, total allocated size in bytes = (approx) 10.5MB.
    I then spawn 32 threads, each of which is passed a unique index into the "node_space" pointer_array (see code below), so each thread is manipulating (reading/writing) a separate 16K block of nodes.
    It should be thread safe and scale by the number of threads because each thread is addressing a different memory block (with no overlap), but multithreading goes no faster (maybe slightly) than a single thread.
    I've tried various threadpool sizes, padding nodes to 16 and 64 byte boundaries,  all to no avail.
    Is this a memory bandwidth problem due to the size of the arrays? Does each thread somehow load the whole 32 blocks?  Any help appreciated.
    struct  Nodes
       unsigned int a;  
       unsigned int b;  
       unsigned int c;
       unsigned int d;  
       unsigned int e;
    typedef struct Nodes  Nodes;
    typedef  Nodes   *Node_Ptr;
    Node_Ptr            node_space[32];          /* pointer array into 32 separate blocks ( loaded via individual calloc calls for each block) */
    .... Thread Spawning  ....
             for (index = 0; index < 32; ++index)
                 CmtScheduleThreadPoolFunction(my_thread_pool_handle, My_Thread_Function, &index, NULL);
    Solved!
    Go to Solution.

    Hello CVI_Rules,
    It's hard to answer your question because it depends on what you are doing in your thread function. Since you are not seeing any speed up in your program when you change the number of threads in your thread pool, you are either doing too much (or all of the work) in each thread, serializing your threads with locks, or somehow slowing down execution in each thread.
    Your basic setup looks fine. You can simplify it slightly by passing the nodes directly to your thread function:
    for (index = 0; index < 32; ++index)
    CmtScheduleThreadPoolFunction(pool, My_Thread_Function, node_space[index], NULL);
    static int My_Thread_Function(void *functionData)
    Node_Ptr nodes = functionData;
     But that's not going to affect performance.
    Things to look into:
    Verify that you're really only working on one subset of the node space in each thread, that you're passing and receiving the correct node space in each thread and that you're working only on that one.
    Verify that you don't have any locks or other synchronization in your program. It sounds like you don't because you designed your program so that it wouldn't need any. But check anyway.
    Verify that you're not doing something unnecessary in your thread function. Sometimes people call ProcessSystemEvents or ProcessDrawEvents because they feel that it makes the UI more responsive. These two functions are expensive (around 20ms per call, I think). So if you are calling these functions in a loop, with a fixed total number of iteraction across all threads, and if the actual computations are relatively fast, then these functions can easily dominate the execution time of your program. (It need not be these functions, it might be other ones. These are just examples.)
    Show and explain your code to a colleague. Sometimes you don't see the obvious until you show it to someone. Or they might notice something.
    Apart from that, can you explain what you are doing in your thread function so that we can have a better understanding of your program and what might inhibit parallelism?

  • Would someone tell me something about multithread and multiprocessor

    Hey, would you be so kind to tell me something about how to progrmme with using multithread in multiprocessro? and where can I find something about it? My problem is that
    Assume that you have to write a computer program that will receive as input a single array
    storing a large number of integers. The program has to compute the prefix sums of the
    number sequence.
    Given a sequence of numbers x1, x2, ..., xn, the prefix sums are the partial sums:
    s1 = x1
    s2 = x1 + x2
    sn = x1 + x2 + ... + xn
    �You have to be prepared to write a program for program should be able to use a variable, user-specified, number of processors. For
    example, the user should be able to run the program using any number of processors P
    between 1 and 16. The number of processors P can either be selected using a command
    line argument or the program can prompt the user.
    �Your program should be able to sum a variable, user-specified, number of integers. The
    integers in the input sequence should be randomly generated inside your program. (That
    is, the user will input n, and the program will then randomly generate n numbers.)
    �Your program should print out (either to the standard output or to a file) in ascending
    order the prefix sums computed: s1, s2, �, sn.
    Can someone give me some help? I have no idea about how to do it?
    thanks a lot of

    I think perhaps you are asking about how to create threads in Java? I'm not sure, but I'll give you some background anyway. Basically all that you need to know is documented in the class java.lang.Thread. If you want a class to run on a separate thread then you can do one of two things:
    (a) define a class that extends Thread.
    (b) define a class that implements Runnable.
    I prefer the latter, but it's up to you. So, for example, if I have some computationally expensive algorithm to execute I would define a class like this:
    public class ImExpensive implements Runnable {
    ����public void run() {
    ��������<insert code here>
    ����}
    Then when you want to run the algorithm you do this:
    ����ImExpensive o = new ImExpensive();
    ����new Thread(o).start();
    The second line in this case constructs a thread that the object 'o' can run on (the start() method causes the run() method in the ImExpensive class to execute).
    Now, as for running on multi-processors, I have never done this so I am not too sure. But all that you have to do is figure out a way of associating the thread that was created with a particular processor.
    Also, be careful when using threads. Everything will be OK if your computations are mutually exclusive (ie: they aren't interdependent). If they aren't then you might run into what is sometimes called "the racehorse problem". This is a phenomenon that occurs because you can't guarantee which threads are going to finish first or indeed the order of interleaved operations. It's difficult to describe but this tutorial may help you out.
    http://java.sun.com/docs/books/tutorial/essential/threads/
    Hope that helps. :)
    Ben

  • Multithread and COMCallback

    Hi ! I've written a program that receives datas from serial port and plot them in a strip chart. The problem is that if too data reaches the pc, the program freezes and dies. I thought to put the ComCallback in another thread and plot blocks of datas for example 5 times per second. But how can I make the COMCallback run inside another thread ??
    Thank you !!

    Hello
    That docuement is an excellant reference, especially if its the first time you are using CVI with multithreading.
    You can also look into using the PostDeferredCallToThread() function inside the callback. allows you to run functions in seperate threads and its really simple to setup. All you need is a thread that stays alive during the process and calls ProcessSystemEvents ( refer to the docuementation for PostDeferredCallToThread() ), and with the thread ID, you can basically tell CVI to call your custom function after the COM callback is called. SO the COM callback will still run in the UI thread, but now you can "defer" the processing inside the callback to run in another thread.
    I hope this helps
    Bilal Durrani
    NI
    Bilal Durrani
    NI

  • MultiThreading and Java IO

    Hello All,
    I have my application running under JBoss 3.2.5 deployed as MBeans.
    All I do in my process is connect to DB (Oracle 8i) create serializedObjects for 1 months data and save it to a folder on the Harddisk. THe size of these objects is approximately 1MB each. When my process runs the 2nd iteration (once per day), it reads this object to get data for 29 days and connects to the DB to fetch data for the current day to complete 30 days, Generates the Object and saves it to the disk. When I have a single process running, It reads quickly from the cache and generates object.
    My problem is when I run the process in multithreads wherein I have 25 - 50 of such Threads in the JVM, it takes awefully long time to generate the files. For eg, while 1 thread takes 3 mins to create a new object, 25 threads in parallel (each reading/writing different files) takes around 1 hr to complete their object.
    Could anyone help me understand my problem. THe server that I have Jboss installed on is an 8 CPU 2.8GHz each box with 8GB RAM running Windows 2003 OS.
    Thanks.

    Parallel thread execution does not help after a certain number of threads because the processor is not actually processing them in parallel. Parallel processing is not truly parallel processing in the strictest sense. The threads are actually queued with time sliced for a single or multiple processor(s) as may be available. That's where multiple processors make a difference, but there will be a limit to the number of processors. Hence, you will not benefit from starting too many threads.
    http://www-128.ibm.com/developerworks/library/j-thread.html
    Threads may be supported by having many hardware processors, by time-slicing a single hardware processor, or by time-slicing many hardware processors.
    http://java.sun.com/docs/books/jls/third_edition/html/memory.html

  • Inheritance and InetAddress

    I'm painfully new to Java so I must be missing something obvious here. Hopefully someone can help me.
    I don't like isReachable in InetAddress so I want to override it with my own isReachable method. The problem is I cannot figure out how to extend the InetAddress class.
    Here is what I have for my new class class:
    package MyProgram;
    include java.net.InetAddress;
    public class MyInetAddress extends InetAddress {
        public boolean isReachable(int timeout) {
             //code here
    }The above will not compile. The compiler returns "class creation was unsuccessful for an unknown reason". A single red X appears next to the extends line above and says "InetAdress() is not public in java.net.InetAddress; cannot be accessed from outstide package".
    I'm using Netbeans 5.0 and JDK 1.5.0_07 on Windows XP SP2.
    So what am I doing wrong? Can I really not extend the InetAddress class?
    Thanks.

    "include" should be "import", and isReachable() has to return a boolean.
    But the more substantial problem is a little more subtle. Every class has got
    to have a constructor - even if it's only the default no argument constructor
    that java supplies. This default constructor does nothing except call the
    parent class's no argument constructor. This process is very important
    because it ensures that constructors are called for all ancestor classes and
    all the necessary initialisation is done.
    Back to your problem. InetAddress does not have a no agument constructor
    (not one that is visible, so you can call it). The only way round this is for you
    to supply a different constructor for MyInetAddress and have it call a different
    constructor of InetAddress. (java is happy so long as some constructor
    is called and all the initialisation can take place.)
    But as you no doubt realise: InetAddress has no visible constructors.
    You are left with no valid way of making a subclass. Sorry.
    You didn't really say why you wanted a subclass. If you don't like
    isReachable(), you dont have to use it!
    Another approach is to have MyInetAddress not subclass InetAddress, but
    rather implement all the methods (it wants to) itself. This is not all that
    hard, because it can have a InetAdress member variable to which it
    delegates: when getAddress() is called on the new class it just returns
    the result of calling getAddress() on the member variable.

  • Issue with Multithreading and vertical scroll bar - help needed to debug!!!

    I have been working on a desktop Visual Studio 2010 application for quite a few years. It is written in C++ and MFC. This code is a combination of code I have written and code I inherited. It worked great for years on Windows XP, but when I ported
    it to Windows 7, a tricky problem has come up that I am having the darnest time trying to figure out
    In summary, it is a single .exe desktop application. There is the main thread (thread A), which launches another thread (thread B). Both threads share a pointer to a single window object which displays events. This window also implements a vertical and horizontal
    scroll bar. 
    The interaction and message processing between the threads seems a little sticky to me. Both threads A and B call the same member function of the CWnd object. BUT, Thread B ALSO posts messages to thread A's queue.
    So, in thread B, you will see code like this, which makes a direct call to the output window object, AND THEN it also posts a message to Thread A's mainframe window like this...
    if( m_pEventLog )
    pOutputWindow->AddLine("Some test...");
    if( m_phNotifyWnd[RECEIVE] && m_puiEventWMsg[RECEIVE] ) {
    ::PostMessage( m_phNotifyWnd[RECEIVE], m_puiEventWMsg[RECEIVE], 0, (LPARAM) pPkt );
    WHEN thread A receives the message that thread B posted above, it only does the following:
    LRESULT CMainFrame::OnSocketReceive( WPARAM, LPARAM lParam )
    CSPkt* pPkt;
    CRWPkt* pRWPkt;
    CSPktSocket* pSocket;
    ULONG ulType;
    CString csTemp;
    CBSWords bsWords;
    CSSSWords sssWords;
    CRWPkt* pLoopBackRWMsg; // used if we have to send a loopback msg back to sender
    CLMsg lmsg;
    m_wndTextWindow.AddLine("Test message");
    return 0;
    So both threads are writing to the output window via the .AddLine() member function.
    void COutputWnd::AddLine( CString& strLine, COLORREF crColor )
    UpdateVScroll();
    return;
    And this function then makes a call to :UpdateVScroll().  The problem seems to arise because thread B does a
    post to thread A, where thread A in turn writes to the output window. Eventually, the program
    HANGS in the call to
    SetScrollInfo() below...
    void COutputWnd::UpdateVScroll()
    CSingleLock lock( &m_CSVertScrollLock ); // lock things up while we are in here
    BOOL bok = lock.Lock();
    if (lock.IsLocked() == TRUE)
    int iMax = m_FifoIndices.GetHighestIndex();
    if( iMax < ( m_iMaxViewableLines - 1 ) )
    iMax = 0;
    //SetScrollRange( SB_VERT, 0, iMax, FALSE );
    //SetScrollRange( SB_VERT, 0, 9, FALSE );
    SCROLLINFO scrollinfo;
    scrollinfo.cbSize = sizeof(SCROLLINFO);
    scrollinfo.fMask = SIF_RANGE;
    scrollinfo.nMin=0;
    scrollinfo.nMax= iMax;
    SetScrollInfo(SB_VERT, &scrollinfo, FALSE);
    lock.Unlock();
    It doesn't take long for the program to hang...maybe about 10 seconds. 
    When I hit DEBUG->BREAK ALL, I get the output below in the CALL STACK WINDOW.
    ntdll.dll!770070f4()
    [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
    user32.dll!76c0cde0()
    user32.dll!76c018d9()
    >
    mfc100d.dll!AfxInternalPumpMessage()  Line 153 + 0x13 bytes
    C++
    mfc100d.dll!CWinThread::PumpMessage()  Line 900
    C++
    mfc100d.dll!CWinThread::Run()  Line 629 + 0xd bytes
    C++
    mfc100d.dll!_AfxThreadEntry(void * pParam=0x0022f6a4)  Line 122 + 0x13 bytes
    C++
    msvcr100d.dll!_callthreadstartex()  Line 314 + 0xf bytes
    C
    msvcr100d.dll!_threadstartex(void * ptd=0x004f97c0)  Line 297
    C
    kernel32.dll!762cee1c()
    ntdll.dll!770237eb()
    ntdll.dll!770237be()
    NOTE: If I never make the call to SetScrollInfo(), the program never HANGS.
    Sooo....I am trying to determine if there is a fundamental issue with the way the threads are communicating that is causing the issue, or if maybe I have a memory overwrite. It always hangs in ::SetScrollInfo(), no matter what I comment and uncomment. This
    makes me think that scroll bat behavior is different in Windows 7 than on XP, but I have not been able to find any documentation about it. 
    Can anyone provide any insight as to what may be the cause of the program hanging>

    It might look like working but it will crash eventually. The windows are thread affine and other thread must never touch other threads windows. Sometimes you might get along but usually it just crashes.
    Thread B must use PostMessage ( or SendMessage if suncronous action is require) to thread A's windows to achieve correct updating. Some very basic calls are implemented directly with SendMessage so they are safe to use but then you must individually check
    which ones are safe.
    Also having multiple SendMessage calls from B to A require rendezvous which might cause other problems ( thread B stalls or program deadlocks, depending on other program structure).
    So PostMessage is the way to do it ( or create yourself another inter-thread mechanism, possible but usually too much troble)

  • Multithreading and static of wdDoModifyView in a view controller

    wdDoModifyView javadoc recommends to use a static variable of view controller (VC) to pass/publish a references of UI elements to event handlers of VC.
    it means then that different instances of VC serving different users share same static variable... i see here a problem, do not you?

    Armin Reichert: see TJA311 WebDynpro Part 1 Unit 10, example optional 1 solution  6-3,6-4 -))
    my new conclusion is that any UI elements should only be access in wdDoModifyView method
    the javadoc discourage from using instance fields not static fields but recommends not to use UIs outside of the method:
    Hook method called to modify a view just before rendering.
    This method conceptually belongs to the view itself, not to the
    controller (cf. MVC pattern).
    It is made static to discourage a way of programming that
    routinely stores references to UI elements in instance fields
    for access by the view controller's event handlers, and so on.
    The Web Dynpro programming model recommends that UI elements can
    only be accessed by code executed within the call to this hook method.

Maybe you are looking for

  • Flash web gallery - style.xml start with slideshow in play?

    When creating a web gallery with Lightroom, using a default flash template, a style.xml sheet is created. Does anyone know the line of code in that style.xml that sets the gallery to load with the slideshow in play mode? thanks, Donnie

  • Certification for Forms 11.1.2 to run on RHEL 6

    Hello, We have Oracle Froms & Reports upgraded 11.1.2 running on RHEL 5. Our System Admins are planning to upgrade O/S to RHEL 6. We have checked the support matrix for Forms & Reports and it says 11.1.1.6 is certified to run on RHEL6 but not 11.1.2.

  • Itunes LP's

    I've seen lots of albums for sale in the iTunes store and there is a notation that it is only playable on a Windows PC or a Mac or on iTunes, Does that mean that they will not play on my iPod?

  • Downloading OWAS - too big

    Is there a way to downoad the OWAS in smaller pieces like the Server. 181 MB is one big download. I checked the Oracle ftp server. In the OAS directory they have 12 smallers tar's labelled a-l but the total size addes up to ~140 MB which seems to sma

  • RMI Server exits early when using SSL

    Hi, Maybe someone else has encountered this one. My RMI server works fine when I use standard sockets. I create an instance and bind it into the rmiregistry. It then waits indefinitely for connections. When I use SSL, I can create the object instance