Multithreading application - how to use correctly if uses network?

I'm coding "daemon"-like software, which do some things in the loop (login to somewhere, do some things and logout) using multithreading.
My application run about 1000-2000 threads and this threads do job.
So here is my htop log at first ~10 minutes:
http://i.stack.imgur.com/wlaeh.png
So you can see on the above screenshot that some number of threads is running (ordered by green R status)
But after some time this happens:
http://i.stack.imgur.com/xf9Ny.png
As you can see just one-three threads are running periodically (it seems like system slow down threads or make it sleeping).
Application run threads for small-time job (it's about 10 seconds to 1 minute) and after thread die Fixed Thread Pool Executor create new threads to do same job.
So as I understand it should be equal speed of threads execution at all times. But it slow down after ~10-20 minutes. Normally running threads in htop up to ~500-200-300-100 threads and down to ~3-30-60 threads at each time. But after this 10-20 minutes just only thread is executing. So can you tell me what is happens and how to fix that?
Or can please anybody contact me at email *[REMOVED BY MODERATOR]* and I'll give source code (it's not big) and *[REMOVED BY MODERATOR]* ?
Edited by: 907212 on Jan 10, 2012 5:45 PM
Edited by: EJP on 11/01/2012 14:57: moderated. Don't post your email address in public places; and this is not a rent-a-coder service. Answers should be posted here.

You don't mention what hardware you are runnng this on and what your software configuration is (os version, java version).
But unless your are on a really big system you will never get 1000 - to 2000 threads doing anything at the same time.
The number of threads that can execute simultaneously is mostly governed by hardware related to the number of processors and the number of cores.
And if a thread isn't one of those that is executing simultaneously then it must be sleeping and not doing any work. With that many threads the biggest percentage of them will always be sleeping.
Threads that are executing will keep executing until they relinquish control (to wait for some event) to another thread; unless you have implemented a homegrown time-slice mechanism that doles out fixed-interval slices to threads in a round-robin fashion.
What drove the decision to use so many threads?
We can provide some suggestions if you give us some information about what the business requirement actually is for your application. Include information about what type of work the threads will actually be doing.
You included one example of logging in, doing some work, and logging out. How many different systems are you connecting to? Are they all Oracle DBs? How often do you connect/reconnect to the same Oracle DB? Depending on the use case your app could benefit by using a connection pool that keeps connections open; there is a high performance cost for opening/closing/reopening connections.

Similar Messages

  • How to use Network utility, or activity monitor

    Hi There,
    Can anyone point me in the direction of something that can tell me more about how to use these programs? Thanks.
    DMWard

    Click here and here for information.
    (33707)

  • Multithreaded Application - How to diagnose

    I ran my multi-threaded application and ended up getting this output. my cpu % shoots up to 95% some time after starting my program. Also, I'd like to know how to debug, diagnose multi-threaded application in general. How to do C like trace and other means.
    Thanks.
    The following is the thread-dump. It was originally for 400 threads. as the char limit exceeded i give here only a portion. And how to attach a file in a post here.
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    2010-04-30 20:09:53
    Full thread dump Java HotSpot(TM) Client VM (10.0-b22 mixed mode, sharing):
    "DestroyJavaVM" prio=10 tid=0xad62a800 nid=0x4690 waiting on condition [0x00000000..0xb7f6b070]
       java.lang.Thread.State: RUNNABLE
    "pool-1-thread-400" prio=10 tid=0xb41ff800 nid=0x4835 runnable [0xad5fe000..0xad5fee20]
       java.lang.Thread.State: RUNNABLE
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
         at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
         at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
         - locked <0x8e825398> (a java.io.BufferedInputStream)
         at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
         at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1000)
         - locked <0x8e812d18> (a sun.net.www.protocol.http.HttpURLConnection)
         at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
         at engine.HttpTask.run(HttpTask.java:51)
         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
         at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:207)
         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
         at java.lang.Thread.run(Thread.java:619)
    "pool-1-thread-1" prio=10 tid=0x09d15000 nid=0x46a4 runnable [0xb56bc000..0xb56bce20]
       java.lang.Thread.State: RUNNABLE
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
         at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
         at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
         - locked <0x8e0bc8c0> (a java.io.BufferedInputStream)
         at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
         at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1000)
         - locked <0x8e0bc8f8> (a sun.net.www.protocol.http.HttpURLConnection)
         at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
         at engine.HttpTask.run(HttpTask.java:51)
         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
         at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:207)
         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
         at java.lang.Thread.run(Thread.java:619)
    "MySQL Statement Cancellation Timer" daemon prio=10 tid=0x09ce3400 nid=0x46a0 in Object.wait() [0xb5721000..0xb57220a0]
       java.lang.Thread.State: WAITING (on object monitor)
         at java.lang.Object.wait(Native Method)
         - waiting on <0x8c702bd0> (a java.util.TaskQueue)
         at java.lang.Object.wait(Object.java:485)
         at java.util.TimerThread.mainLoop(Timer.java:483)
         - locked <0x8c702bd0> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "Low Memory Detector" daemon prio=10 tid=0x09a5dc00 nid=0x469d runnable [0x00000000..0x00000000]
       java.lang.Thread.State: RUNNABLE
    "CompilerThread0" daemon prio=10 tid=0x09a53000 nid=0x469c waiting on condition [0x00000000..0xb5a4dad8]
       java.lang.Thread.State: RUNNABLE
    "Signal Dispatcher" daemon prio=10 tid=0x09a51c00 nid=0x469b waiting on condition [0x00000000..0x00000000]
       java.lang.Thread.State: RUNNABLE
    "Finalizer" daemon prio=10 tid=0x09a4d000 nid=0x469a in Object.wait() [0xb5cef000..0xb5ceff20]
       java.lang.Thread.State: WAITING (on object monitor)
         at java.lang.Object.wait(Native Method)
         - waiting on <0x8c6b8870> (a java.lang.ref.ReferenceQueue$Lock)
         at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
         - locked <0x8c6b8870> (a java.lang.ref.ReferenceQueue$Lock)
         at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
         at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
    "Reference Handler" daemon prio=10 tid=0x09a48800 nid=0x4699 in Object.wait() [0xb5d40000..0xb5d40da0]
       java.lang.Thread.State: WAITING (on object monitor)
         at java.lang.Object.wait(Native Method)
         - waiting on <0x8c6b88f8> (a java.lang.ref.Reference$Lock)
         at java.lang.Object.wait(Object.java:485)
         at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
         - locked <0x8c6b88f8> (a java.lang.ref.Reference$Lock)
    "VM Thread" prio=10 tid=0x09a47400 nid=0x4697 runnable
    "VM Periodic Task Thread" prio=10 tid=0x09a71400 nid=0x469e waiting on condition
    JNI global references: 869
    Heap
    def new generation   total 4544K, used 830K [0x8c1c0000, 0x8c6a0000, 0x8c6a0000)
      eden space 4096K,   9% used [0x8c1c0000, 0x8c21fb10, 0x8c5c0000)
      from space 448K, 100% used [0x8c5c0000, 0x8c630000, 0x8c630000)
      to   space 448K,   0% used [0x8c630000, 0x8c630000, 0x8c6a0000)
    tenured generation   total 60544K, used 39479K [0x8c6a0000, 0x901c0000, 0x901c0000)
       the space 60544K,  65% used [0x8c6a0000, 0x8ed2dce8, 0x8ed2de00, 0x901c0000)
    compacting perm gen  total 12288K, used 2177K [0x901c0000, 0x90dc0000, 0x941c0000)
       the space 12288K,  17% used [0x901c0000, 0x903e0518, 0x903e0600, 0x90dc0000)
        ro space 8192K,  73% used [0x941c0000, 0x947a34a0, 0x947a3600, 0x949c0000)
        rw space 12288K,  58% used [0x949c0000, 0x950b8668, 0x950b8800, 0x955c0000)

    itsraja wrote:
    I ran my multi-threaded application and ended up getting this output. my cpu % shoots up to 95% some time after starting my program. Also, I'd like to know how to debug, diagnose multi-threaded application in general. How to do C like trace and other means. Use a profiler. There are many different ones.
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap spaceThis indicates that you are either allocating too much memory, or are leaking memory. The VM will usually consume much cpu just before an OutOfMemoryError due to lots of call to the garbage collector.
    Use a memory profiler to see why, and where the problem is.

  • How to use /Network/Library/Fonts

    I have several computers (some running OSX 10.5, some 10.4) connected on a home LAN. I'd like to centralize my font management so I don't have to manually install fonts on every machine.
    Apple suggests I could put all my fonts in /Network/Library/Fonts and have them shared among the computers, but doesn't give any details: http://support.apple.com/kb/HT2435
    I see that all my machines have a /Network directory, but it's empty. Anyone know how I can set this up? Thanks!!

    Hi
    The KB article says:
    +"The Network folder is for fonts shared among all users of a local area network. This feature is normally used on network file servers, under the control of a network administrator."+
    For this to work the way you want it to you would need OSX Server. There may be someone who could possibly outline how this can be done in a non-server environment (doubtful) over on the Server Forum:
    http://discussions.apple.com/category.jspa?categoryID=96
    Tony

  • How to use network path on a script ?

    Hi everyone,
    I need to use a network path like \\myserv\myfolder\myaep.aep on a var like
    var myPNG = new File("\\myserv\myfolder\myaep.aep");
    var myImportOptions = new ImportOptions (myPNG);
    , but AE don't seem to understand network paths, i've got the error message "Incorrect path. Path : C:\myserv\myfolder\myaep.aep"
    Can someone help me ?
    PS : i'm new at scripting and sorry for my english i'm french

    app.project.item(index).replace(new file('http:////distilleryimage10.s3.amazonaws.com//4419faf222c211e29b3722000a1fa50e_7.jpg'));
    app.project.item(index).replace(new file('http:\\\\distilleryimage10.s3.amazonaws.com\\4419faf222c211e29b3722000a1fa50e_7.jpg '));
    I have tried several methods to get a url to load. I been successful with network paths, and since I could do a http:/ with a import command from the GUI, thought I could do it from script.
    I get the same results, with the local path added to the beginning of the url and all slashes reduced to only one.
    Any ideas would be appreciated. Thanks
    David

  • How i use my network at home for iphone dy usb

    how i use network at home for iphone by USB

    Look for documentation on setting up a SOCKS Proxy for Linux. Installation on the Mac is almost identical. Here's a good place to start.
    <http://www.linux.org/apps/all/Daemons/Proxy.html>

  • Consuming a jms queue from a multithread application

    Hi
    Thank you for reading my post.
    I have an application which shuld consume message of a queue.
    my application is multithread and what i want to know is:
    - How i can ask queue to remove a message after my thread finished its work with the message, by this way i can ensure that if my thread face an exception after it read the message my message will not lose.
    - As it is multithread application, How i can ensure that a message is not delivered to two or more thread? is there any way to consume the messages in a synchronized way?
    Will synchronized access restrict the performance?
    Thanks

    This is running in a J2DK environment. For my thread pool, I just copied one from a Sun tutorial on multi-threading then modified it. I creaed a seperate package with three classes. Here is my thread pooling package. I basically use a Vector to hold threads when they are not working. And you can set a limit as to the max number of active threads.
    package threadpooling;
    * @author cferris
    *  This class is simple to wrap the runnable
    *  thread for the worker thread around other
    *  needed parameters like salon id and source.
    public class TaskWrapper {
      // Define the needed instance fields.
      public  Runnable taskAtHand = null;
      public  String taskType = "";
        // Overloaded constructor.
        public TaskWrapper(Runnable task) {
          // Just set the runnable
          taskAtHand = task;
          taskType = "WorkerThread";
        }  // of overloaded contructor
        // Overloaded constructor.
        public TaskWrapper(Runnable task, String taskType) {
          // Just set the instance fields
          taskAtHand = task;
          this.taskType = taskType;
        }  // of overloaded contructor
    package threadpooling;
    * @author cferris
    *  This class is for tracking the number of
    *  active threads so we don't go over the set
    *  limit. This class basically synchronizes
    *  the methods that update the active thread
    *  counter.
    import java.util.*;
    public class ThreadPool {
      // Define the instance fields.
      //   First define instance fields for the
      //   management of the thread pools - pm.
      protected Vector poolOfThreads = new Vector();
      private  static LinkedList taskQueue = new LinkedList();
      private  static int poolSize = 0;
      private  static boolean pmAvailable = true;
      private  static boolean daemon = false;
      public   static boolean shutDown = false;
      //   Instance field for the management of
      //   the threads - tm.
      private  static int activeThreads = 0;
      private  static int maxReached = 0;
      private  static int numTimesReached = 0;
      private  static boolean tmAvailable = true;
      // Define constants
      private  static final int MAX_LIMIT_DEFAULT = 32;
        // The constructor.
        public ThreadPool() {
          this(MAX_LIMIT_DEFAULT, false);
        }  // of constructor
        // Overload the constructor with max number of active jobs.
        public ThreadPool(int poolSize, boolean daemon) {
          this.poolSize = poolSize;
          this.daemon = daemon;
          poolOfThreads = new Vector();
          taskQueue = new LinkedList();
          salonTracker = new Vector();
          // Load up and initialize the threads.
          for (int i=0; i < poolSize; i++) {
              Thread thread = new WorkerThread(this, i);
              thread.setDaemon(daemon);
              thread.start();
              poolOfThreads.add(thread);
        }  // of overloaded constructor
        // Overload this method to allow just the runnable task.
        public void assignWork(Runnable work) {
          // Create the wrapper
          TaskWrapper wrapper = new TaskWrapper(work, "A task");
          assignWork(wrapper);
        }  // of overloaded assignWork
        // Push a unit of work (work thread) on the the worker thread.
        public synchronized void assignWork(TaskWrapper work) {
          // First increament the active thread count.
          increment();
          // Wait until we can access the linked list 
          try {
              if (!pmAvailable)
                  wait();
          } catch(InterruptedException e) { }
          pmAvailable = false;
          notifyAll();
          taskQueue.addLast(work);
          pmAvailable = true;
          notifyAll();
        }  // of assignWork
        // Get the next unit of work (work thread).
        public synchronized TaskWrapper getNextWorkAssignment()  {
          // Wait until we can access the linked list 
          try {
              if (!pmAvailable)
                  wait();
          } catch(InterruptedException e) { }
          pmAvailable = false;
          notifyAll();
          TaskWrapper nextTask;
          if (!taskQueue.isEmpty())
              nextTask = (TaskWrapper)taskQueue.removeFirst();
          else
              nextTask = null;
          pmAvailable = true;
          notifyAll();    
          return nextTask;
        }  // of getNextWorkAssignment
        // Return the number of tasks waiting on the work queue.
        public synchronized int workWaiting()  {
          // Wait until we can access the linked list 
          try {
              if (!pmAvailable)
                  wait();
          } catch(InterruptedException e) { }
          pmAvailable = false;
          notifyAll();
          int qSize = taskQueue.size();
          pmAvailable = true;
          notifyAll();    
          return qSize;
        }  // of workWaiting
        // Wait until all the tasks have been completed.
        public void waitForCompletion() {
          int prev = 0;
          // Continue checking untill all the threads have
          // completed and been removed.
          while(!poolOfThreads.isEmpty()) {
             // Lets record the difference
             if (poolOfThreads.size() != prev) {
                 System.out.println("waiting for " + poolOfThreads.size() + " to complete");
                 prev = poolOfThreads.size();
             // Loop through the thread pool and check each thread.         
             for (int t = 0; t < poolOfThreads.size(); t++)
                  if (!((WorkerThread)poolOfThreads.get(t)).working)
                      // This thead is done so remove it.
                      poolOfThreads.remove(t);
          }  // of while
        } // waitForCompletion
        // Set the max number of allow threads.
        public synchronized void setPoolSize(int newLimit) {
          // just set the limit.
          // Check if available
          while (!tmAvailable) {
             try {
               wait();
             catch(InterruptedException ie) {
               System.exit(5);
          // Ok, lock the object while we update it.
          tmAvailable = false;
          notifyAll();
          poolSize = newLimit;
          // Reset the max counters/trackers too
          maxReached = 0;
          numTimesReached = 0;
          // Create additional threads in the pool if needed
          if (poolSize > poolOfThreads.size())
              // Load up and initialize the threads.
              for (int i = poolOfThreads.size(); i < poolSize; i++) {
                  Thread thread = new WorkerThread(this, i);
                  thread.start();
                  poolOfThreads.add(thread);
          // Done, now release the object.
          tmAvailable = true;
          notifyAll();       
        }  // of setPoolSize.
        // The method to increment thread counter.
        private synchronized void increment() {
          // Check if available
          while (!tmAvailable) {
             try {
               wait();
             catch(InterruptedException ie) {
               // logger.fatal("Synchronized error in ThreadPool "); 
               // logger.fatal("Error message is: " + ie.getMessage());
               System.exit(5);
          // Ok, lock the object while we update it.
          tmAvailable = false;
          notifyAll();
          activeThreads++;
          // Check if this is the highest number of threads
          // that has been active, if not then set so.
          if (activeThreads > maxReached)
              maxReached = activeThreads;
          if (activeThreads == poolSize)
              numTimesReached++;
          // Done, now release the object.
          tmAvailable = true;
          notifyAll(); 
        }  // of increment
        // The method to increment thread counter.
        public synchronized void decrement() {
          // Check if available
          while (!tmAvailable) {
             try {
               wait();
             catch(InterruptedException ie) {
               // logger.fatal("Synchronized error in ThreadPool "); 
               // logger.fatal("Error message is: " + ie.getMessage());
               System.exit(5);
          // Ok, lock the object while we update it.
          tmAvailable = false;
          notifyAll();
          activeThreads--;
          // Done, now release the object.
          tmAvailable = true;
          notifyAll(); 
        }  // of decrement
        // A method to determine if the maximum number of active
        // threads has been reached.
        public synchronized boolean limitNotReached() {
          boolean limit = false;
          // Check if available
          while (!tmAvailable) {
             try {
               wait();
             catch(InterruptedException ie) {
               // logger.fatal("Synchronized error in ThreadPool."); 
               // logger.fatal("Error message is: " + ie.getMessage());
               System.exit(5);
          // Ok, lock the object while we update it.
          tmAvailable = false;
          notifyAll();
          if (activeThreads < poolSize)
             limit = true;
          // Done, now release the object.
          tmAvailable = true;
          notifyAll();
          return limit;
        }  // of limitNotReached
        // A method to return the number of active threads.
        public synchronized int currentNum() {
          // Check if available
          while (!tmAvailable) {
             try {
               wait();
             catch(InterruptedException ie) {
               // logger.fatal("Synchronized error in ThreadPool"); 
               // logger.fatal("Error message is: " + ie.getMessage());
               System.exit(5);
          // Ok, lock the object while we update it.
          tmAvailable = false;
          notifyAll();
          int numberOf = activeThreads;
          // Done, now release the object.
          tmAvailable = true;
          notifyAll();
          return numberOf;
        }  // of currentNum
    package threadpooling;
    * @author cferris
    *   This is the work thread that receives the
    *   taskes or unit of work that make up the
    *   thread pool.
    public class WorkerThread extends Thread {
      // Define need instance fields.
      public  boolean working = true;
      public  int id = 0;
      private int pauseFactor = 1;
      // The thread pool that this object belongs to.
      public ThreadPool owner;
      // Define the constructor for the seperate thread.
      public WorkerThread(ThreadPool pooler, int id)  {
        owner = pooler;
        this.id = id;
      }  // of contructor
      //  Wait for work or for system shutdown.
      public void run() {
        // Define the work object. 
        TaskWrapper unitOfWork = null;
        // Wait for work or until system is shutting down.
        do {
           unitOfWork = owner.getNextWorkAssignment();
           if (unitOfWork != null) {
               // First set name and then add salon to watch list.
               String taskName = unitOfWork.taskType + "-" + id;
               setName(taskName);
            // System.out.println("Starting thread - " + getName());
               unitOfWork.taskAtHand.run();
               // Done, now adjust tracker and reset the pause factor.
               owner.decrement();
               pauseFactor = 1;
           else {
               // No work so pause a bit
               try {
                   sleep(150 * pauseFactor);
               } catch (InterruptedException e) { }
               // If consecutively pausing because of no work then
               // increase the pause time up to a point.
               if (pauseFactor < 49)
                   pauseFactor++;
        } while (!owner.shutDown);
        // Set indicator this thread in the pool is done.
        working = false; 
      }  // of run
    }To use the thread pool just create a static instance of the ThreadPool in your main class
      private  static ThreadPool threadPool = new ThreadPool(getMaxThreads(), useDaemon());Then to launch a new thread use this.
        if (runOnSeperateThread()) {  
            WriteTransThread task = new WriteTransThread(messasge);
            // Add to the thread pool.
            threadPool.assignWork(new TaskWrapper(task, "my thread"));
      private boolean runOnSeperateThread() {
        // First check if mutli threading is turned on
        // and if there are open threads.
        if (multiThreadingOn && threadPool.limitNotReached())
            // Yes, there are open threads.
            return true;
        // Check if we can wait for an open thread.
        if (!multiThreadingOn || !waitForOpenThread)
            // No multi threading or waiting allowed.
            return false;
        // OK, wait for an open thread, wait for up
        // to 90 seconds.
        int j = 0;
        do {
            try {
                // Wait 1/2 a second.
                Thread.sleep(500);
            } catch(InterruptedException ignore) { };
            // Check again for an optn thread.
            if (threadPool.limitNotReached())
                // Ok to run on separate thread.
                return true;
            // Increament counter and wait again.
            j++;
        } while(j < 180);
        // If we got this far then we've waited long enough.
        logger.warn("Reached limit on waiting for an open thread in the pool");
        return false;
      }  // of runOnSeperateThreadThe WriteTransThread is a class that will extract the message body and write out its data to a table.
    Last, before you end your program make sure all the threads have competed by calling the following.
      //  If multi-threading is activated then this method will
      //  wait for them to complete before returning. The
      //  max wait time is 300 secs or 5 minutes.
      private void waitForThreadsToComplete(String message) {
        // First check for multi threading. 
        if (prop.useMultiThread() && (threadPool.currentNum() > 0)) {
            int limit = 0;       
            // Some threads are still active, wait
            logger.info("Waiting for threads to complete before " + message
                      + " current thread count is " + threadPool.currentNum());
            do {
               limit++;
               try {
                   Thread.sleep(500);  // Sleep 1/2 a sec.
               } catch(InterruptedException ie) { }  // Ignore the error for now.
               // Max waith is 300 sec or 5 min.
            } while ((threadPool.currentNum() > 0) && (limit < 600));
      }  // of waitForThreadsToComplete
     

  • Using time() function in multithreaded application

    I am using time() function in a multithreaded application with NULL argument for getting current time.
    Some time it's observed that we get a time one minute earlier than current time (3600 seconds).
    Is there a problem in the usage of the function?
    I am using expression : currenttime = time(NULL);
    I had seen some people using following way - time(&currenttime );
    Will above two behaves differently in multithreaded environment?
    [I  am using  Sun C++ 5.5 compiler on Solaris 8]

    How do you compare actual time against the time seen by your threads? If your threads are printing the value from time(2) to stdout, it's possible that you're seeing an artifact of thread scheduling and/or output buffering.
    I really doubt that you have a concurrency problem, but anyway make sure that you include the -mt option on your compile line:
    CC -mt blahblahblah...

  • Using 10.6.8, internet pdf documents not opening using Adobe Reader; how is this corrected?

    Using 10.6.8, internet pdf documents not opening using Adobe Reader; how is this corrected?  I've tried changing "sharing and permissions" to "read and write" as suggested on other help sites, but this did not correct the problem.

    I had the same problem---contacted Adobe and their service rep helped me by
    A.   Deleting  Adobe Reader from my iMac's Applications in Finder
    B.   Downloading Google Chrome browser and then
    C.   Downloading the latest Adobe Reader for Mac 10.6.8 in Google Chrome--it works
    Adobe acknowledges problem with the latest Snow Leopard update 10.6.8 and with this work around, I can open PDF's using the Google Chrome Browser.
    Is this the ideal solution---NO.  Safari is my main browser. I now have to use a separate browser for PDF's.
    Am I happy to be able to open PDF's---YES
    You can't believe the time I spent to solve this problem before calling Adobe for help. My Apple Care policy expired a month ago . As I use Photoshop Elements, I was not charged by Adobe for their help on the telephone.

  • How to use Xcelsius tool in Desktop applications

    Hello
    This is shankar, from IMS CRM4 team in SAP. We have a requirement for interactive anlalytics in our product and found that Xcelisus is the correct approach.
    Can you please clarify the following
    1. How to use the Xcelsius tool in desktop applications.
    2. Is Xcelsius Viewer free version available which can used only to view the interactive analytics. Xcelsius designer is not required for all the users.
    Thank You
    Shankar

    Hello Victor
    Thank you for your inputs !!
    Point 2 is very clear to me that we do not need any additional software to run the SWF files.
    We have CRM Mobile offline product with Crystal reports integrated already. CRM Mobile Offline solution is a desktop application and there is no intutive analytics.
    So i would like to know more on how to link the data (Excel or XML) to Xcelisus tool and get the output SWF file. Can it be done through the command line (without using Xcelsius designer) ??. Do we need to have any licensed version of Xcelisus for this task??
    This will promote both our prodcut and BOBJ Xcelisus prodcut as well
    Regards
    Shankar

  • Screen image clips at the bottom, not so when using explorer-how do i correct this?

    screen images such as games and submit buttons don`t show at bottom of screen. they do using explorer ,same screen setting, how do i correct

    Is this in the normal browser window or in (smaller) pop-up windows?
    It is possible that the screen is too wide or too high.
    * Use Restore or Maximize in the right-click context menu of the Taskbar icon to set focus to the Firefox application if you do not see the Firefox window.
    * Open the system menu of that Firefox window via Alt+Space and see if you can move and resize that window (use the keyboard cursor keys).
    If that works then first close all other open Firefox windows and then close Firefox via "File > Exit/Quit" to save that setting.
    If the above didn't help then see:
    * http://kb.mozillazine.org/Corrupt_localstore.rdf

  • Is it supported to use Microsoft JDBC driver use in Java 7 (and 8) multithreaded applications?

    Hello everone
    is it supported to use Microsoft JDBC driver (the latest version) with Java 7 multithreaded application?
    I am planning to use standard Java 7 threads library and use separate JDBC objects per each thread, i.e. Java threads will not share any JDBC objects among them, only the thread-safe Java collections/data structures will be shared between threads (such as
    ConcurrentHashMap etc). The JDBC connections, resultsets, statements, etc will be created and dedicated per each individual thread.
    If it is supported - do you expect this design to scale-up well or am I better off using multiple but single-threaded Java/JBDC programs to access SQL Server 2012/2014 from Microsoft JDBC driver?
    Thanks
    Yuri Budilov
    Yuri Budilov Melbourne Australia

    >is it supported to use Microsoft JDBC driver (the latest version) with Java 7 multithreaded application?
    Yes, so long as:
    > Java threads will not share any JDBC objects among them,
    >do you expect this design to scale-up well or am I better off using multiple but single-threaded Java/JBDC programs >to access SQL Server 2012/2014 from Microsoft JDBC driver?
    Using threads should scale better than using processes (at least on Windows), as there is quite a bit of overhead with a process.  Each process has it's own JRE, it's own GC heap, its own threads...
    The bigger question, though, is how this scales on the SQL Server.  Your throughput may be limited by resources on your database server, and the thread's workloads may not be able to run concurrently because of locking. 
    David
    David http://blogs.msdn.com/b/dbrowne/

  • How to use Adobe Edge Web Fonts correctly

    I am a Dreamweaver newbie and am trying to learn how to use it through the tutorials. I am stuck at part 3 trying to use Adobe Edge Web Fonts correctly in my web site. As far as I can tell I have followed the instructions in the tutorial correctly, but the font style effect does not show up on my site. I am working on a Windows 7 machine and using Dreamweaver 5.5. I have copied and pasted the javascript into the correct spot in the head of the index.html page as well as included the font-family name in the CSS file and saved the whole smash. The source code for my index page looks exactly like the sample in the tutorial, and I have tried to view my site in my browser, but no dice. Doesn't display the Edge Web Font style in the web page. I believe I've done everything according to the directions, but I suppose I've missed some small detail. Any suggestions greatly appreciated

    You need to add a <script> to the head of your documents like the example below.  In my example, I'm using all of the aguafina-script and league-gothic fonts.
    <!--Edge Font-->
    <script src="//use.edgefonts.net/aguafina-script:n4:all;league-gothic:n4:all.js"></script>
    CSS:
         h1 {
         font-family: league-gothic, sans-serif;
         font-weight:bold;
         color: #639;
         font-size: 250%;
    A simple way to get the correct codes is to go to Adobe Edge Web Fonts and select the font you wish to use.
    https://edgewebfonts.adobe.com/fonts
    NOTE: You won't see the custom web fonts displayed in Design View, Live View or when previewed locally unless you use a local testing server.  An easier way to test is by uploading the page to your remote server.
    Hope this helps,
    Nancy O.

  • How to use JDBC Connection Pools in a standalone application?

    Hi, there,
    I have a question about how to use JDBC Connection Pools in an application. I know well about connection pool itself, but I am not quite sure how to keep the pool management object alive all the time to avoid being destroyed by garbage collection.
    for example, at the website: http://www.developer.com/java/other/article.php/626291, there is a simple connection pool implementation. there are three classes:JDBCConnection, the application's gateway to the database; JDBCConnectionImpl, the real class/object to provide connection; and JDBCPool, the management class to manage connection pool composed by JDBCConnectionImpl. JDBCPool is designed by Singleton pattern to make sure only one instance. supposing there is only one client to use connection for many times, I guess it's ok because this client first needs instantiate JDBCPool and JDBCConnectionImpl and then will hold the reference to JDBCPool all the time. but how about many clients want to use this JDBCPool? supposing client1 finishes using JDBCPool and quits, then JDBCPool will be destroyed by garbage collection since there is no reference to it, also all the connections of JDBCConnectionImpl in this pool will be destroyed too. that means the next client needs recreate pool and connections! so my question is that if there is a way to keep pool management instance alive all the time to provide connection to any client at any time. I guess maybe I can set the pool management class as daemon thread to solve this problem, but I am not quite sure. besides, there is some other problems about daemon thread, for example, how to make sure there is only one daemon instance? how to quit it gracefully? because once the whole application quits, the daemon thread also quits by force. in that case, all the connections in the pool won't get chance to close.
    I know there is another solution by JNDI if we develop servlet application. Tomcat provides an easy way to setup JNDI database pooling source that is available to JSP and Servlet. but how about a standalone application? I mean there is no JNDI service provider. it seems a good solution to combine Commons DBCP with JNID or Apache's Naming (http://jakarta.apache.org/commons/dbcp/index.html). but still, I don't know how to keep pool management instance alive all the time. once we create a JNDI enviroment or naming, if it will save in the memory automatically all the time? or we must implement it as a daemon thread?
    any hint will be great apprieciated!
    Sam

    To my knoledge the pool management instance stays alive as long as the pool is alive. What you have to figure out is how to keep a reference to it if you need to later access it.

  • How to Use Mobile Service in HTML/JavaScript Application

    The Windows Azure Mobile Service is a back end tool for mobile applications. It supports various platforms, such as Windows Store, Windows Phone 8, iOS and Android. The Windows Azure
    Mobile service can also support HTML/JavaScript. This article helps you to get a basic idea of how to use the Windows Azure Mobile Service in HTML/JavaScript applications.
    Let us start with a Quick startup project provided by Microsoft. A Quick startup is a simple demo project that can help us to understand how to use the Windows Azure Mobile Service with HTML/JavaScript. So let's start from the Quick startup project.
    Login into in the Windows Azure portal and use the following procedure.
    This article assumes you already have a Windows Azure account and the mobile service is enabled in your account.
    1. Create a new Windows Azure Mobile Service
    Click on the +New button from the left corner and select Compute -> Mobile Service and then click on the "Create" button.
    The Windows Azure portal popup creates a mobile service wizard when you click the Create button. Windows Azure asks you to enter the mobile service name as shown in the following image:
    Select the database options and region for your mobile service and click on the "Next" button.
    Once your mobile service is successfully created, the portal will show all your mobile services as shown in the following images.
    Ok! We have created a new mobile service successfully. Let's move to our subsequent steps.
    1. Quick startup Project 
    As we all know, the Windows Azure Mobile Service can support many platforms such as Windows Store, Windows Phone 8, iOS, Android and HTML/JavaScript. This article only tells us about the new HTML/JavaScript platform that is recently added to the Windows Azure
    Mobile Service.
    In the image above, we are in the quick startup page where the Windows Azure Mobile Service allows the user to choose their platform. I have selected the HTML/JavaScript Platform.
    In the image above, we found 3 quick steps that can allow us to run <g class="gr_ gr_74 gr-alert gr_gramm Grammar" data-gr-id="74" id="74">a HTML/JavaScript</g> sample project. 
    1. Create Table: In this step the user needs to create a table that can used by the sample project, once you hit the create TodoItem Table button. The Portal will create a TodoItem table in your mobile service. You
    can check this table by clicking on the data tab(menu).
    2. Download and run your app: In this step the user needs to download the Quick startup project that is provided by the Windows Azure portal. Click on the "Download" button and download the project. You will
    see the following files in the quick startup project.
    The Server folder contains some files to setup this project locally. The user should run the file from the server folder corresponding to their OS. I am using Windows OS so I ran the <g class="gr_ gr_80 gr-alert gr_spell ContextualSpelling ins-del multiReplace"
    data-gr-id="80" id="80">lanch</g>-<g class="gr_ gr_79 gr-alert gr_spell ContextualSpelling ins-del multiReplace" data-gr-id="79" id="79">windwos</g> file to setup this project locally in
    IISExpress.
    Press r and enter the key, you will see IISExpress started. Do not close this Windows and open your browser and request the http://localhost:8000/ page.
    Enter the Item name and click on the add button. Your Item will be added to the TodoItem table.
    3. Configure your host name: This step is a very important step for any HTML/JavaScript application that uses the Windows Azure Mobile Service. In this <g class="gr_ gr_83 gr-alert gr_gramm Punctuation only-ins
    replaceWithoutSep" data-gr-id="83" id="83">step</g> the user must register their website name in the Cross-origin resource sharing (CORS). By default, "localhost" is added by the Windows Azure Mobile Service
    so your quick startup project can run without making any CORS setting changes. The user can add their website domain name by clicking on the configure tab (menu).
    The user can add as many website domain names as needed.

    are you asking a question or did you just post a tutorial here? you might want to post it as a blog post or wiki entry instead.

Maybe you are looking for

  • CS2 crashes when I make a web gallery.

    MacBookPro is generating peculiar greek prerence files when I use PS CS2. Have uninstalled and reinstalled. Still can't make a web gallery and still crashes on web gallery. Have archived and reinstalled system. Any suggestions???

  • Essbase server cube deployment error

    Hi All , I have installed essbase 11.1.2 in windows machine with oracle DB. i have tried both the options . cube deployment wizard-> data source setting - 1) ODBC (Essbase dynamic create option) 2) ODBC(DSN name) while deploying a cube in server 11.1

  • Can't open ipod nano

    i can't open my nano and connect it to my computer, i don't know what's the matter....... plz help me

  • No burner on project computer

    I don't have a DVD burner on the computer that I'm making my project on but I do have one on my computer at work. What is the best way to get my project to work and burn it there?

  • Right section?

    I would like to ask a question regarding Oracle XML DB and a problem I am having when generating XML with SQL. Is this the right section for such a question? Please advise.