Return thread's runtime?

Is there anyway to get the runtime of a thread when calling the start() method? My intention is to kick off a number of threads, have those threads run in parallel and finish, then output some sort of report about which thread completed in the shorted amount of time, the longest amount of time, etc....
I'm doing something along these lines ....
import java.util.Date;
import java.io.*;
public class LdapSearchThreaded extends Thread  {
        long threadTime;
        public LdapSearchThreaded(String str) {
                super(str);
        public void run() {
                long startTime = start.getTime();
                Date now = new Date();
                System.out.println("START: " + getName());
                //************* do a bunch of stuff
                Date stop = new Date();
                long stopTime = stop.getTime();
                threadTime = stopTime - startTime;
class ThreadedSearch {
        public static void main (String[] args) {
                for (int i = 0; i<5; i++){
                        LdapSearchThreaded search = new LdapSearchThreaded("Thread_" + i);
                        search.start();
                // output stats on all the treads......
}Thanks!

You could do:
public class LdapSearchThreaded extends Thread  {
    public long getThreadTime() {
        return threadTime;
    public boolean hasThreadEnded() {
        return threadTime != 0;
class ThreadedSearch {
    public static void main (String[] args) {
        ArrayList searchList = new ArrayList();
        for (int i = 0; i<5; i++) {
                LdapSearchThreaded search = new LdapSearchThreaded("Thread_" + i);
                search.start();
                searchList.add(search);
        // output stats on all the treads......
}

Similar Messages

  • 100 threads using Runtime in Eclipse

    Hello,
    My purpose is to run 100 threads, which will be running php programs.
    As long as these programs php are identicall there is no problem.
    The problem is when there are 100 different programs. - Threads are still alive and never finish. The code looks like:
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    class MyRunnableClass implements Runnable
              public MyRunnableClass (String program)
                   inputToPhp[0]="php";
                   inputToPhp[1]="-r";
                   inputToPhp[2]=program;
              public void run()
                   try
                   {      r = Runtime.getRuntime();
                        p = r.exec(inputToPhp);
                   catch( IOException f)
                        System.err.println("IOException!");
                        p.destroy();
                   try
                   {p.waitFor();}
                   catch( InterruptedException e )
                   {p.destroy();}
         reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
              private BufferedReader reader;
              private String[] inputToPhp = new String[3];
              private Runtime r;
              private Process p;
    public class Population
    public static void main(String args[])
         int POPULATION=100;
         int delay = 1000;
         int nMills= 10000;
         int nTimes = nMills/delay;
         String[] programs= {}; //...
                        //contains 100 different simple programs without errors
                        // for example "echo('something');"
         MyRunnableClass[] r = new MyRunnableClass[POPULATION];
         Thread[] php = new Thread[POPULATION];
    // here I'm starting all threads
         for (int i=0;i<POPULATION;i++)
                   r = new MyRunnableClass(programs[i]);
                   php[i] = new Thread(r[i]);
                   php[i].start();
    // here I'm waiting 10 secunds
         for(int k=0;k<nTimes;k++)
              try
                   Thread.sleep(delay);
              } catch (InterruptedException e) {}
    // here I'm expecting that all threads are finished, but they aren't and still running...why ??
         for (int i=0;i<POPULATION;i++)
                   if ( php[i].isAlive() )
                        php[i].interrupt();
                        System.out.println("Interrupted thread " + i );
    Thanks, Pawel

    PawelPawel wrote:
    NO, I'm reading the output, but it's not important here and I didn't want to put to long code.
    I assigned this like "//..."Only after the process has finished, however, and if the buffers fill before the process finishes?
    Like I said, read that link.
    Edit: Arrgh. And automatically simply killing the things. This entire "project"/"design"/"brainchild" is just plain wrong.

  • Thread run() can't return an object?

    I am using threads with Runtime.exec() to run system commands (like ps command on Unix) and I need to have the method return what the executed commands return e.g. the response from the ps command; however, the run() method in the Thread interface is void.
    Is there any way around this?

    hello David,
    as far as i understand with thread, it doesn't return anything, if you like you could create a static class or method (setter and getter) that would contain the values you need.. and once in a while check it..
    say, in your thread it will get a response right? after the Runtime.exec(), you call the class set method, then in the calling class of the thread, put a loop.. as i understand you have to wait for the runtime.exec reply.. so, try to put a loop that would call the class get method.
    i hope it helps,
    Ronron

  • What's wrong with my multi-threaded Matrix Mult. code? 1 thread is fastest

    For some reason, 1 thread performs the best. What's wrong with my implementation?
    import java.util.Random;
    import java.util.Date;
    import java.util.concurrent.ExecutorService;
    import java.util.concurrent.Executors;
    import java.util.concurrent.TimeUnit;
    public class Matrix {     
         private int values[][];
         private int rows;
         private int columns;
         public Matrix(int r, int c) {
              this.rows = r;
              this.columns = c;
              this.values = new int[r][c];
         private void randomize() {
              Random generator = new Random();
              for (int r = 0; r < this.rows; r++) {
                   for (int c = 0; c < this.columns; c++) {
                        this.values[r][c] = generator.nextInt(10);
         public String toString() {
              String out = "";
              for (int r = 0; r < this.rows; r++) {
                   for (int c = 0; c < this.columns; c++) {
                        if (c == 0) out += "[";
                        else out += "\t";
                        out += this.values[r][c];
                   out += "]\n";
              return out;
         public boolean equals(Object obj) {
              Matrix other = (Matrix) obj;
              if (this.columns != other.columns || this.rows != other.rows)  {
                   return false;
              for (int r = 0; r < this.rows; r++) {
                   for (int c = 0; c < this.columns; c++) {
                        if (this.values[r][c] != other.values[r][c]) {
                             return false;
              return true;
         // matrix multiplication using single thread
         public Matrix times(Matrix other) {
              assert(this.columns == other.rows);
              Matrix out = new Matrix(this.rows, other.columns);
              for (int r = 0; r < this.rows; r++) {
                   for (int c = 0; c < other.columns; c++) {
                        int dotProduct = 0;
                        for (int z = 0; z < this.columns; z++) {
                             dotProduct += this.values[r][z] * other.values[z][c];
                        out.values[r][c] = dotProduct;
              return out;
         // matrix multiplication with many threads
         public Matrix ptimes(Matrix other, int numberOfThreads) throws InterruptedException { // parallel
              assert(this.columns == other.rows);
              Matrix out = new Matrix(this.rows, other.columns);
              ExecutorService threadExecutor = Executors.newFixedThreadPool(numberOfThreads);
              for (int r = 0; r < this.rows; r++) {
                   for (int c = 0; c < other.columns; c++) {
                        threadExecutor.execute(new HelperThread(r, c, this, other, out));
              threadExecutor.shutdown();
              threadExecutor.awaitTermination(2, TimeUnit.DAYS);
              return out;
         private class HelperThread implements Runnable {
              private int row;
              private int col;
              private Matrix a;
              private Matrix b;
              private Matrix out;
              HelperThread(int r, int c, Matrix a, Matrix b, Matrix o) {
                   this.row = r;
                   this.col = c;
                   this.a = a;
                   this.b = b;
                   this.out = o;
              public void run() {
                   int dotProduct = 0;
                   for (int z = 0; z < a.columns; z++) {
                        dotProduct += this.a.values[row][z] * this.b.values[z][col];
                   this.out.values[row][col] = dotProduct;
         public static void main(String[] args) throws InterruptedException {
              int size = 100;
              Matrix a = new Matrix(size, size);
              a.randomize();     
              Matrix b = new Matrix(size, size);
              b.randomize();
              for (int t = 1; t < 15; t++) {
                   long start = new Date().getTime();
                   System.out.print(t + " threads: ");
                   Matrix c = a.ptimes(b, t);
                   //System.out.println(c);
                   long finish = new Date().getTime();
                   System.out.println((finish - start) + " milliseconds");
                   Matrix d = a.times(b);
                   assert(c.equals(d));
    }

    This one is even faster. On my dual core I get:
    Warmup
    Single Threaded
    5.20616 milliseconds
    5.52872 milliseconds
    5.12708 milliseconds
    5.59048 milliseconds
    5.16104 milliseconds
    5.1838 milliseconds
    5.37104 milliseconds
    5.1788 milliseconds
    5.18636 milliseconds
    5.15736 milliseconds
    Multi Threaded with 2 threads
    3.22184 milliseconds
    2.86552 milliseconds
    2.86284 milliseconds
    3.67032 milliseconds
    3.08032 milliseconds
    2.97388 milliseconds
    2.93084 milliseconds
    3.44012 milliseconds
    2.89744 milliseconds
    2.88136 milliseconds
    As you can see the Multi-Threaded versions are now faster.
        // matrix multiplication with many threads
        ExecutorService threadExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
        public Matrix ptimes(Matrix other) throws InterruptedException, ExecutionException {
            assert (this.columns == other.rows);
            Matrix out = new Matrix(this.rows, other.columns);
            Future futures[] = new Future[rows];
            for (int r = 0; r < this.rows; r++) {
                futures[r] = threadExecutor.submit(new HelperThread(r, this, other, out));
            for(Future f : futures) {
                f.get();
            return out;
        private class HelperThread implements Callable<Object> {
            private int row;
            private Matrix a;
            private Matrix b;
            private Matrix out;
            HelperThread(int r, Matrix a, Matrix b, Matrix o) {
                this.row = r;
                this.a = a;
                this.b = b;
                this.out = o;
            public String call() throws Exception {
                int dotProduct = 0;
                for (int c = 0; c < b.columns; c++) {
                    for (int z = 0; z < a.columns; z++) {
                        dotProduct += this.a.values[row][z] * this.b.values[z][c];
                    this.out.values[row][c] = dotProduct;
                return null;
        public static void main(String[] args) throws InterruptedException, ExecutionException {
            int size = 100;
            Matrix a = new Matrix(size, size);
            a.randomize();
            Matrix b = new Matrix(size, size);
            b.randomize();
            System.out.println("Warmup");
            for (int t = 0; t < 1000; t++) {
                Matrix c = a.ptimes(b);
                Matrix d = a.times(b);
                assert (c.equals(d));
            System.out.println("Single Threaded");
            for (int t = 0; t < 10; t++) {
                long start = System.nanoTime();
                Matrix d = a.times(b);
                long finish = System.nanoTime();
                System.out.println((finish - start)/1000000.0 + " milliseconds");
            System.out.println("Multi Threaded with " + Runtime.getRuntime().availableProcessors() + " threads");
            for (int t = 0; t < 10; t++) {
                long start = System.nanoTime();
                Matrix c = a.ptimes(b);
                long finish = System.nanoTime();
                System.out.println((finish - start)/1000000.0 + " milliseconds");
                Matrix d = a.times(b);
                assert (c.equals(d));
            System.exit(0);
        }

  • Start a new java process using Runtime.Exec() seems to ignore the -Xmx

    I am working with a process that requires a minimum of 1.5 GB to run and works better if more is available.
    So I am determining how much memory is available at startup and restarting the jre by calling
    Runtime.exec("java -Dcom.sun.management.jmxremote=true -Xmx1500M -jar XXX.jar")
    which reinvokes the same process with a new max memory size.
    The initial call to the process is
    java -Dcom.sun.management.jmxremote=true -Xmx3500M -jar XXX.jar
    The initial call returns 3262251008 from Runtime.maxmemory()
    When reinvoked through Runtime.exec() as above
    Runtime.maxmemory() still returns 3262251008
    Is there a way to separate the new process from the size specified by the parent process?

    That is strange. Here is a program I wrote which calls itself recursively.
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.List;
    import java.util.ArrayList;
    import static java.util.Arrays.asList;
    public class MemorySize {
        public static void main(String... args) throws IOException, InterruptedException {
            System.out.println("Maximum memory size= "+Runtime.getRuntime().maxMemory());
            if (args.length == 0) return;
            List<String> cmd = new ArrayList<String>();
            cmd.add("java");
            cmd.add("-cp");
            cmd.add(System.getProperty("java.class.path"));
            cmd.add("-Xmx"+args[0]+'m');
            cmd.add("MemorySize");
            cmd.addAll(asList(args).subList(1,args.length));
            Process p = new ProcessBuilder(cmd).start();
            readin(p.getErrorStream());
            readin(p.getInputStream());
        private static void readin(final InputStream in) {
            new Thread(new Runnable() {
                public void run() {
                    try {
                        byte[] bytes = new byte[1024];
                        int len;
                        while((len = in.read(bytes))>0)
                            System.out.write(bytes, 0, len);
                        in.close();
                    } catch (IOException e) {
                        e.printStackTrace();
            }).start();
    }If you run this with the args 128 96 33 222 it prints out
    Maximum memory size= 66650112
    Maximum memory size= 133234688
    Maximum memory size= 99942400
    Maximum memory size= 35389440
    Maximum memory size= 231014400

  • Multi-thread serialization

    In order to bench my database i made an application that just call some procedures (rselect only no update or insert).
    The application instanciate 15 threads, each with a connection to my database.
    My problem is that it seems that my calls are serialiazed and take a lot of time to answer.
    But if I launch multiple instances of my application ( each with only 1 thread) I don't have this problem.
    How can I avoid this problem ?
    Thanks, bernard

    Here's the test code I've been using for ad-hoc multi-threaded testing; it's a bit sloppy, but it works and I no longer have time to finish the project up right and pretty. At the risk of derision from the better Java programmers here, I post it and hereby dedicate this mess to the public domain. Enjoy...
    3 Java files.
    File 1:
    import java.util.ArrayList;
    public class DBTest {
        public static void main (String args[]) {
            TestHarness testSuite1;
            ArrayList testSet1 = new ArrayList();
            for ( int i=0; i< 2; i++) {
                testSet1.add(new Check1(2) );
            testSuite1 = new TestHarness (testSet1);
            testSuite1.go();
            testSuite1.report(System.out);
    class Check1 extends Thread {
        private long runLength;
        private int myThreadNumber;
        private static int threadNumber = 0;
        private static Object lockObj = new Object();
        public Check1 (int _runLength) {
            runLength = _runLength;
            synchronized(lockObj) {
                myThreadNumber = threadNumber++;
        public Check1 () {
            this(10);
        public void run () {
            try {
                BusyDB workload = new BusyDB();
                workload.beBusy (runLength, myThreadNumber);
            catch (InterruptedException e) {
                System.err.println("Interrupted !");
            catch (Exception e) {
                e.printStackTrace(System.err);
        public String toString() {
            return "thread " + myThreadNumber + ": iterated for " + runLength + " iterations\n";
    }File 2:
    import java.sql.*;
    public class BusyDB
            private static long iterModulus = 1000;
            public void beBusy(long iterations, int threadID)
                    throws Exception
                    Class.forName("oracle.jdbc.driver.OracleDriver");
                    Connection con = null;
                    PreparedStatement ps1;
                    ResultSet rs1;
                    int i = 0;
                    try {
                            while ( i < iterations )
                            con = DriverManager.getConnection("jdbc:oracle:thin:user/password@db_host:1521:db_sid");
                            con.setAutoCommit(false);
                            ps1 = con.prepareStatement("select sysdate from dual");
                            rs1 = ps1.executeQuery();
                            i++;
                            if (i % iterModulus == 0)
                                    System.out.println("Thread number " + threadID +": " + iterModulus
                                                            + " more iterations " + i + " total iterations");
                                    con.commit();
                            rs1.close();
                            if( con != null ) con.close();
                    catch (Exception e)
                            e.printStackTrace(System.out);
                            i = i + 1;
                    } finally {
                            if( con != null ) con.close();
    }File 3:
    import java.io.PrintStream;
    import java.util.Collection;
    import java.util.Iterator;
    public class TestHarness
        private Collection subTests;
        private boolean wasInterrupted = false;
        private final long created = System.currentTimeMillis();
        private long start, end;
        private String testSuiteName;
        public TestHarness ( Collection subTests ) {
            this.subTests = subTests;
            this.testSuiteName = "anonymous";
        public void go () {
            start = System.currentTimeMillis();
            System.out.println("Test suite " + testSuiteName + " started: " + start);
            Iterator i = subTests.iterator();
            while (i.hasNext() ) ((Thread)i.next() ).start();
            System.out.println("All subtests finished starting at: " + System.currentTimeMillis() );
            i = subTests.iterator();
            try {
                while (i.hasNext() ) {
                    ((Thread)i.next() ).join();
            catch (InterruptedException e) {
                wasInterrupted = true;
            end = System.currentTimeMillis();
            System.out.println("All subtests finished running at: " + end );
        public void report( PrintStream out) {
            out.println ("\nTest Suite: " + testSuiteName);
            out.println ("Runtime millis: " + (end - start) );
            Iterator i = subTests.iterator();
            while (i.hasNext() ) out.print( i.next().toString() );
            if (wasInterrupted) {
                out.println("======== ERROR ========");
                out.println("Test thread interrupted");
    }

  • How to find Number of working threads using java executor framework

    I'm creating a java thread pool using java 1.5 executor framework.
    private ExecutorService executorService = Executors.newFixedThreadPool(threadPoolSize);
    public <T> Future<T> submit(Callable<T> task) {
              return executorService.submit(task);
    }Now I want to get the number of working thread at runtime. Is there any java api available to do this using java 1.5 executor framework?
    Thanks,
    Arpan

    If the ExecutorService you are working on is a ThreadPoolExecutor then you can use ThreadPoolExecutor#getActiveCount() to get the count of threads actually running tasks. There is no such method on the ExecutorService interface though.

  • Help with Runtime class and timeout of Process

    Hi,
    Question regarding using Runtime class, and yes I have looked at the javadocs, but I am still confused and frustrated.
    Here is part of my code.
    Process p;
    Runtime runtime = Runtime.getRuntime();
    p = runtime.exec("rsh localhost ls");
    if you are not familiar with rsh all it does is remote shell into the computer localhost and executes the command ls.
    Now, I dont have rsh running on my computer so it will hang at that line for about 40 sec and eventually time out on its own. Is there anyway I can specify a timeout argument like there is for the ping command? Like if there is no response from localhost after 3 sec, then just kill the process?
    I looked at the Runtime javadoc and Process javadoc and the closest thing I could come to with is something to do with envp (environment parameters), but I dont know what that is.
    Thanks guys.

    You can't timeout the "runtime.exec("rsh localhost ls");" call but if you execute the call in a seperate thread you can "timeout" and continue executing on the original thread (while letting the "runtime" thread to timeout on its own).
    Check the following class that I created for cases like this:
    abstract public class TimeoutHelper implements Runnable
        private Throwable error;
        private boolean running = true;
        private Object retValue;
        protected String name;
        private long waitTime;
        private Thread thread;
         * Creates a new helper. Use {@link #start} to run the code.
         * @param name A name that will be used in the helper thread name
         * @param waitTime The time (in msec) to wait before timeout.
        public TimeoutHelper(String name, long waitTime)
            this.name = name;
            this.waitTime = waitTime;
        public Object start() throws Throwable
            return asyncExecute();
        abstract protected Object execute() throws Throwable;
        private synchronized Object asyncExecute() throws Throwable
            createThread().start();
            if (running)
                try
                    wait(waitTime);
                    if (running)
                        // Timeout!!
                        abortThread();
                        throw new TimeOutException("Timeout for: " + name);
                catch (InterruptedException ie)
                    // Ignore
            if (error != null)
                throw error;
            return retValue;
        private void abortThread()
            if (thread != null)
                thread.interrupt();
        protected Thread createThread()
            thread = new Thread(this, name);
            return thread;
        public void run()
            try
                retValue = execute();
            catch (Throwable th)
                error = th;
            synchronized (this)
                running = false;
                notifyAll();
    }You use the class by extending it and implementing "execute". For example:
            TimeoutHelper helper = new TimeoutHelper("Runner", 5000)
                protected Object execute() throws Throwable
                    Runtime runtime = Runtime.getRuntime();
                    return runtime.exec("rsh localhost ls");
            try
                Process p = (Process)helper.start();
            catch (TimeOutException e)
                // Handle timeout here
            catch (Exception e)
                // Handle other errors here.
            }

  • Shall I make a new thread daily until my issue is addressed? POPPING/CRACKLING

    Windows 7 x64 Professional and my X-Fi Titanium card on 2.7.007 drivers.
    The card randomly crackles, changing the bitrate in windows 7's audio control panel resolves the issue temorarily but it will resurface.
    The Temporary fix:
    Sound -> Speaker Properties -> Advanced - and changing the format from 24bit/48000Hz to anything else and then back to 24bit/48000Hz resolves the issue, and the crackling immediately sto
    ps.
    Running voice software(Ventrilo, Teamspeak, etc.)? immediately causes the audio service audiodg.exe to use 0-% cpu at all times, regardless if the voice software is enabled or actually in use. enabling advertised modes above 48khz for the input results in drastic increases 20-60% cpu for idling in? voice program.
    Creative no longer responds to my support tickets. If I open a new ticket they send me a generic response and then continue not to communicate with me.
    This is clearly an issue with their poor drivers wich have not been updated since July 2009. Also my motherboard is an AMD chipset board, not an nforce, which i have specified in every support ticket and they still have linked me to the article pertaining to the nforce motherboard issue.
    There are no words hostile enough to express my disdain for Creative Labs.

    Ok, this is a rather complex scenario and I'm not quite sure if I got the correct picture of what you're doing, so maybe I'm going in the wrong direction with this...
    First of all, you should distinguish between threads and processes. A thread is a strand of program execution within a process. A process is an application running on the operating system. Your java application is a process, and it may include several threads. Runtime#exec(...) will actually invoke a process, that is, it will start a program which runs asynchronously and (more or less) independant from the JVM. You'll need to wait for this process to finish before proceeding with the next script. Runtime#exec(...) will return an instance of Process, which provides the method Process#waitFor() to do just that.
    Looking at your code except, you don't really have to start a separate java thread for what you're doing. Your main thread will immediately block and wait for the worker anyway, so you might just invoke Runtime#exec(...) directly.
    By the way, if you want to wait for a java thread to terminate, there is a better way of doing it than looping while the thread is still alive. The Thread#join() method will block until the target thread terminates.

  • Thr_create() returns -1 which isn't specified in the man page. What is -1?

    Hello,
    I'm for the first time experimenting with Solaris threads as I'm porting an AIX app. over to Solaris.
    Anyhow, I have a sample program that creates a simple thread. For some reason, the return value of of the initial thr_create is -1, which isn't specified in the man page for thr_create. The man page lists the following return values, non of which are -1:
    RETURN VALUES
    Zero indicates a successful return and a non-zero value
    indicates an error.
    ERRORS
    If any of the following conditions occur, these functions
    fail and return the corresponding value:
    EAGAIN The system-imposed limit on the total number
    of threads in a process has been exceeded or
    some system resource has been exceeded (for
    example, too many LWPs were created).
    EINVAL The value specified by attr is invalid.
    If any of the following conditions are detected,
    pthread_create() fails and returns the corresponding value:
    ENOMEM Not enough memory was available to create the
    new thread.
    If any of the following conditions are detected,
    thr_create() fails and returns the corresponding value:
    EINVAL o stack_base is not NULL and stack_size is
    less than the value returned by
    thr_min_stack(3T).
    o stack_base is NULL and stack_size is not
    zero and is less than the value returned by
    thr_min_stack(3T).
    However, I don't see a -1 there and therefore, don't know what this means.
    Here is the simple code that I wrote for this experiment as well as the output. It doesn't get too far into the program before exiting - I've bolded where it exits:
    #define _REENTRANT
    #include <stdio.h>
    #include <thread.h>
    #include <errno.h>
    /* Function prototypes for thread routines */
    void sub_a(void );
    void sub_b(void );
    void sub_c(void );
    void sub_d(void );
    void sub_e(void );
    void sub_f(void );
    thread_t thr_a, thr_b, thr_c;
    void main()
    thread_t main_thr;
    int rc = 0;
    main_thr = thr_self();
    printf("Main thread = %d\n", main_thr);
    if (rc = thr_create(NULL, 0, sub_b, NULL, THR_NEW_LWP, &thr_b))
    printf("\n rc = %d",rc);
    switch(rc)
    case EAGAIN: printf("This one1");
    break;
    case EINVAL: printf("This one2");
    break;
    case ENOMEM: printf("This one3");
    break;
    default: printf("rc = %d");
    break;
    fprintf(stderr,"Can't create thr_b\n"),
    * exit(1); *
    /* if (thr_create(NULL, 0, sub_a, (void *)thr_b, THR_NEW_LWP, &thr_a))
    fprintf(stderr,"Can't create thr_a\n"), exit(1); */
    if (thr_create(NULL, 0, sub_c, (void *)main_thr, THR_NEW_LWP, &thr_c))
    fprintf(stderr,"Can't create thr_c\n"), exit(1);
    printf("Main Created threads A:%d B:%d C:%d\n", thr_a, thr_b, thr_c);
    printf("Main Thread exiting...\n");
    thr_exit((void *)main_thr);
    void sub_a(void arg)
    thread_t thr_b = (thread_t) arg;
    thread_t thr_d;
    int i;
    printf("A: In thread A...\n");
    if (thr_create(NULL, 0, sub_d, (void *)thr_b, THR_NEW_LWP, &thr_d))
    fprintf(stderr, "Can't create thr_d\n"), exit(1);
    printf("A: Created thread D:%d\n", thr_d);
    /* process
    for (i=0;i<1000000*(int)thr_self();i++);
    printf("A: Thread exiting...\n");
    thr_exit((void *)77);
    void * sub_b(void *arg)
    int i;
    printf("B: In thread B...\n");
    /* process
    for (i=0;i<1000000*(int)thr_self();i++);
    printf("B: Thread exiting...\n");
    thr_exit((void *)66);
    void * sub_c(void *arg)
    void *status;
    int i;
    thread_t main_thr, ret_thr;
    main_thr = (thread_t)arg;
    printf("C: In thread C...\n");
    if (thr_create(NULL, 0, sub_f, (void *)0, THR_BOUND|THR_DAEMON, NULL))
    fprintf(stderr, "Can't create thr_f\n"), exit(1);
    printf("C: Join main thread\n");
    if (thr_join(main_thr,(thread_t *)&ret_thr, &status))
    fprintf(stderr, "thr_join Error\n"), exit(1);
    printf("C: Main thread (%d) returned thread (%d) w/status %d\n", main_thr, ret_thr, (int) status);
    /* process
    for (i=0;i<1000000*(int)thr_self();i++);
    printf("C: Thread exiting...\n");
    thr_exit((void *)88);
    void * sub_d(void *arg)
    thread_t thr_b = (thread_t) arg;
    int i;
    thread_t thr_e, ret_thr;
    void *status;
    printf("D: In thread D...\n");
    if (thr_create(NULL, 0, sub_e, NULL, THR_NEW_LWP, &thr_e))
    fprintf(stderr,"Can't create thr_e\n"), exit(1);
    printf("D: Created thread E:%d\n", thr_e);
    printf("D: Continue B thread = %d\n", thr_b);
    thr_continue(thr_b);
    printf("D: Join E thread\n");
    if(thr_join(thr_e,(thread_t *)&ret_thr, &status))
    fprintf(stderr,"thr_join Error\n"), exit(1);
    printf("D: E thread (%d) returned thread (%d) w/status %d\n", thr_e,
    ret_thr, (int) status);
    /* process
    for (i=0;i<1000000*(int)thr_self();i++);
    printf("D: Thread exiting...\n");
    thr_exit((void *)55);
    void * sub_e(void *arg)
    int i;
    thread_t ret_thr;
    void *status;
    printf("E: In thread E...\n");
    printf("E: Join A thread\n");
    if(thr_join(thr_a,(thread_t *)&ret_thr, &status))
    fprintf(stderr,"thr_join Error\n"), exit(1);
    printf("E: A thread (%d) returned thread (%d) w/status %d\n", ret_thr, ret_thr, (int) status);
    printf("E: Join B thread\n");
    if(thr_join(thr_b,(thread_t *)&ret_thr, &status))
    fprintf(stderr,"thr_join Error\n"), exit(1);
    printf("E: B thread (%d) returned thread (%d) w/status %d\n", thr_b, ret_thr, (int) status);
    printf("E: Join C thread\n");
    if(thr_join(thr_c,(thread_t *)&ret_thr, &status))
    fprintf(stderr,"thr_join Error\n"), exit(1);
    printf("E: C thread (%d) returned thread (%d) w/status %d\n", thr_c, ret_thr, (int) status);
    for (i=0;i<1000000*(int)thr_self();i++);
    printf("E: Thread exiting...\n");
    thr_exit((void *)44);
    void sub_f(void arg)
    int i;
    printf("F: In thread F...\n");
    while (1) {
    for (i=0;i<10000000;i++);
    printf("F: Thread F is still running...\n");
    OUTPUT:
    # /emc/smithr15/solthread
    Main thread = 1
    rc = -1Can't create thr_b
    rc = -1#
    Any ideas as to what -1 indicates and how to solve this?
    Thanks for your response,
    dedham_ma_man

    ok, my bad. I wasn't linking in the -lthread library.
    Thanks anyway.

  • Is there a way to figure out what the current thread is?

    I've got the following snippet of code:
    // create a new thread. If the current thread is not this new thread, return
    Thread CountDownThread = new Thread("CountDownThread");
    CountDownThread.start();
    if (/*CURRENT THREAD*/.getName() != CountDownThread.getName()) {
         System.out.println ("I'm not CountDownThread. I'm leaving.");
         return;
    // current thread should be new thread. Therefore start the countdown
    CurrTime = InitTime;
    while(CurrTime.charAt(0) != '-') {      // go until current time is negative
         CurrTime = C.countDown();       // returns the current time based on the difference between the initial and elapsed time
         setText(CurrTime);                   // display current time in JLabel
    C.reset();
    setText(C.getCurrTime());What I'm trying to do is get a clock (C) to count down and display the time remaining in a JLabel (this snippet is taken from a method within that very JLabel which I'm extending from javax.swing.JLabel). While it's counting down, I'd like for the program to go off and do other things. Therefore, I'm trying to create a new thread that carries out the task of counting down while the original/main thread moves on to do other things.
    Please have a look at the above code and tell me if I'm on the right track. The one thing I don't know how to do is figure out how to tell which thread the current thread is. I'm assuming that both the new thread and original/main one will execute the if statement, the new one after it returns from start() (which I haven't defined). The original/main one will detect that it is not the new thread and return, whereas the new thread will and go on to the while loop. In the while loop, it will count down the clock until it reaches 0, after which point it will reset it and die.
    If I'm on the right track, all I need to know is how to detect which thread is currently executing. If I'm not on the right track, what would be the best way to do this?

    What? No! No Thread terminates on the return of start(). Those two events are unrelated!Uh... I think you misunderstood what I said.
    I didn't say that CountDownThread terminates upon returning from start() (which is what it sounds like you interpreted from me); I said that the thread that CountDownThread creates terminates once CountDownThread returns from start() (i.e. like any other local variable/object). This, of course, assumes that CountDownThread has a Runnable object on which to call its run() method (am I right?), in which case my code above doesn't create a new thread at all (i.e. CountDownThread.start() is executed within the main/original thread) - am I right?
    No, run() doesn't call start()! That would be stupid.Again, you misunderstood. I shouldn't need to explain this one. A simple reference to an ordinary dictionary on the words 'former' and 'latter' should suffice :)
    Anyway, all joking aside, I have now improved my code and it works! Here's what it looks like:
    ClockJLabel.java
    package MazeMania.clock;
    public class ClockJLabel extends javax.swing.JLabel {
    private Clock C;
    private ClockJLabelsRunnable CJLR;
    public ClockJLabel() {
      C = new Clock();
      CJLR = new ClockJLabelsRunnable();
      setText(C.getCurrTime()); // should be 00:00:00:00
      setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
      // need to figure out how to set the size so that it sticks
      setForeground(new java.awt.Color(255, 0, 0));
      setBackground(new java.awt.Color(0, 0, 0));
      setOpaque(true);
    // starts the clock counting up indefinitely from 0
    public void start() {
      (new Thread(new Runnable() {
        public void run() {
         while(true) setText(C.getElapsedTime());
       })).start();
      //System.out.println("Started clock...");
    // starts the clock counting down from an initial time and runs this count down in a separate thread
    public void countDown(String InitTime) {
      // initialize the clock
      try {C.initClock(InitTime);}
      catch(java.text.ParseException PE) {
       System.out.println(PE.getMessage());
      // initialize JLabel's display
      setText(C.getCurrTime());
      // prepare Runnable and give it to new Thread. New Thread starts count down.
      CJLR.task = CJLR.COUNTDOWN;
      CJLR.CJL = this;
      Thread CountDownThread = new Thread(CJLR);
      CountDownThread.start();
    public Clock getClock() {
      return C;
    }ClockJLabelsRunnable
    package MazeMania.clock;
    import java.lang.Runnable;
    class ClockJLabelsRunnable implements Runnable {
    public static int COUNTDOWN = 1;
    public static int COUNTUP = 2;
    // NOTE: this Runnable doesn't test for the proper setting of these variables
    public int task = 0;
    public ClockJLabel CJL = null;
    public void run() {
      Clock C = CJL.getClock();
      while(C.countDown().charAt(0) != '-') {CJL.setText(C.getCurrTime());}
      C.reset();
      CJL.setText(C.getCurrTime());

  • Threading with connection pool

    Hi
    My application is an interface to ldap directory. I have not used any ldap open source api to retrieve data from ldap. I have written connection pool that will help the application to connect to the ldap. It's working fine, but it's creating threads which are not invited.
    ConnectionPool class takes care of the connection storage and creation, while Housekeeping thread relases these connection when idle after a given time.
    Can someone please help in finding the problem in the code that creates additional threads.
    package com.ba.cdLookup.manager;
    import com.ba.cdLookup.exception.CDLookupException;
    import com.ba.cdLookup.server.CdLookupProperties;
    import java.util.Vector;
    import javax.naming.Context;
    import javax.naming.NamingException;
    public class HouseKeeperThread extends Thread {
             * Apache Logger to log erro/info/debug statements.
        protected static org.apache.commons.logging.Log log = org.apache.axis.components.logger.LogFactory
             .getLog(HouseKeeperThread.class.getName());
        private static HouseKeeperThread houseKeeperThread;
             * Close all connections existing.
             * @param connections
             *                void
        private void closeConnections(Vector connections) {
         String methodIdentifier = "closeConnections";
         int numOfConn = connections.size();
         try {
             for (int i = 0; i < numOfConn; i++) {
              Context context = (Context) connections.get(i);
              if (context != null) {
                  context.close();
                  context = null;
                  connections.remove(i);
                  numOfConn--;
                  log.info(" connection name:" + context
                       + " removed. Threadcount =" + (connections.size()));
         } catch (NamingException e) {
             String errMsg = "CDLdapBuilder connect() - failure while releasing connection "
                  + " Exception is " + e.toString();
             log.error(errMsg);
         } catch (Exception e) {
             String errMsg = "CDLdapBuilder connect() - failure while releasing connection "
                  + " Exception is " + e.toString();
             log.error(errMsg);
             * Thread run method
        public void run() {
         String methodIdentifier = "run";
         try {
             while(true){
              log.debug("house keeping :" + this + " ---sleep");
              //sleep(100000);
              log.debug("house keeping :" + this + " startd after sleep");
               sleep(CdLookupProperties.getHouseKeepConnectionTime());
              ConnectionPool connectionPool = ConnectionPool
                   .getConnectionPool();
              Vector connList = connectionPool.getAvailableConnections();
              closeConnections(connList);
         } catch (CDLookupException cde) {
             log.error(methodIdentifier + " " + cde.getStackTrace());
         } catch (InterruptedException ie) {
             log.error(methodIdentifier + " " + ie.getStackTrace());
         * @param connectionPool
         * @return
         * Thread
        public static Thread getInstance() {
         if(houseKeeperThread==null){
             houseKeeperThread = new HouseKeeperThread();
         return houseKeeperThread ;
    package com.ba.cdLookup.manager;
    import com.ba.cdLookup.exception.CDLookupException;
    import com.ba.cdLookup.server.CdLookupProperties;
    import com.ba.cdwebservice.schema.cdLookupPacket.LookupFailureReasons;
    import java.util.Properties;
    import java.util.Vector;
    import javax.naming.Context;
    import javax.naming.NamingException;
    import javax.naming.directory.DirContext;
    import javax.naming.directory.InitialDirContext;
    * ConnectionPool class manages, allocates LDAP connections. It works as a lazy
    * binder and retrieves connections only when required. It doesn't allow
    * connection greater then the maximum connection stated.
    * To retrieve a connection the singelton method getConnectionPool is to used,
    * which retruns thread safe singleton object for the connection.
    public class ConnectionPool implements Runnable {
        private int initialConnections = 0;
        private int maxConnections = 0;
        private boolean waitIfBusy = false;
        private Vector availableConnections, busyConnections;
        private boolean connectionPending = false;
        private static int threadCount = 0;
             * classIdentifier
        private final String classIdentifier = "ConnectionPool";
             * Apache Logger to log erro/info/debug statements.
        protected static org.apache.commons.logging.Log log = org.apache.axis.components.logger.LogFactory
             .getLog(CDLdapBuilder.class.getName());
             * To get the attribute a systemaccessfor out of the search result
        private String vendorContextFactoryClass = "com.sun.jndi.ldap.LdapCtxFactory";// "com.ibm.jndi.LDAPCtxFactory";
             * context factory to use
        private String ldapServerUrl = "LDAP://test.ldap.com"; // default ldap
             * server live used by default
        private String searchBase;
             * environment properties.
        private Properties env;
             * DirContext
        private javax.naming.directory.DirContext ctx;
             * default search base to be used in Corporate Directory searches
        private String defaultSearchBase = "dc=Pathway";
             * search criteria
        private String searchAttributes;
             * search filter to retrieve data from CD
        private String searchFilter;
             * CorporateDirectoryLookup Constructor
             * <p>
             * loads the setup parameters from the properties file and stores them
             * Makes a connection to the directory and sets default search base
             * @throws CDLookupException
             * @throws CDLookupException
        private ConnectionPool() throws CDLookupException {
         this.maxConnections = CdLookupProperties.getMaxConnection();// maxConnections;
         this.initialConnections = CdLookupProperties.getInitialConnection();
         this.waitIfBusy = CdLookupProperties.isWaitIfBusy();
         this.searchBase = CdLookupProperties.getDefaultSearchBase();
         //for local env testing
    //      this.maxConnections = 5;
    //      this.initialConnections = 1;
    //      this.waitIfBusy = true;
             * For keeping no of connections in the connection pool if
             * (initialConnections > maxConnections) { initialConnections =
             * maxConnections; }
         availableConnections = new Vector(maxConnections);
         busyConnections = new Vector(maxConnections);
         for (int i = 0; i < maxConnections; i++) {
             availableConnections.add(makeNewConnection());
             *  ConnectionPoolHolder provide Thread safe singleton
             *         instance of ConnectionPool class
        private static class ConnectionPoolHolder {
             * connection pool instance
         private static ConnectionPool connectionPool = null;
             * If no ConnectionPool object is present, it creates instance of
             * ConnectionPool class and initiates thread on that.
             * @return ConnectionPool Returns singleton object of ConnectionPool
             *         class.
             * @throws CDLookupException
         private static ConnectionPool getInstance() throws CDLookupException {
             if (connectionPool == null) {
              connectionPool = new ConnectionPool();
              new Thread(connectionPool).start();
              // Initiate house keeping thread.
              HouseKeeperThread.getInstance().start();
             return connectionPool;
             * Returns singleton object of ConnectionPool class.
             * @return ConnectionPool
             * @throws CDLookupException
        public static ConnectionPool getConnectionPool() throws CDLookupException {
         return ConnectionPoolHolder.getInstance();
             * getConnection retrieves connections to the corp directory. In case
             * there is no available connections in the pool then it'll try to
             * create one, if the max connection limit for the connection pool
             * reaches then this waits to retrieve one.
             * @return Context
             * @throws CDLookupException
        public synchronized Context getConnection() throws CDLookupException {
         String methodIdentifier = "getConnection";
         if (!availableConnections.isEmpty()) {
             int connectionSize = availableConnections.size() - 1;
             DirContext existingConnection = (DirContext) availableConnections
                  .get(connectionSize);
             availableConnections.remove(connectionSize);
                     * If connection on available list is closed (e.g., it timed
                     * out), then remove it from available list and repeat the
                     * process of obtaining a connection. Also wake up threads that
                     * were waiting for a connection because maxConnection limit was
                     * reached.
             if (existingConnection == null) {
              notifyAll(); // Freed up a spot for anybody waiting
              return (getConnection());
             } else {
              busyConnections.add(existingConnection);
              return (existingConnection);
         } else {
                     * Three possible cases: 1) You haven't reached maxConnections
                     * limit. So establish one in the background if there isn't
                     * already one pending, then wait for the next available
                     * connection (whether or not it was the newly established one).
                     * 2) You reached maxConnections limit and waitIfBusy flag is
                     * false. Throw SQLException in such a case. 3) You reached
                     * maxConnections limit and waitIfBusy flag is true. Then do the
                     * same thing as in second part of step 1: wait for next
                     * available connection.
             if ((totalConnections() < maxConnections) && !connectionPending) {
              makeBackgroundConnection();
             } else if (!waitIfBusy) {
              throw new CDLookupException("Connection limit reached", 0);
                     * Wait for either a new connection to be established (if you
                     * called makeBackgroundConnection) or for an existing
                     * connection to be freed up.
             try {
              wait();
             } catch (InterruptedException ie) {
              String errMsg = "Exception raised =" + ie.getStackTrace();
              log.error(errMsg);
              throw new CDLookupException(classIdentifier, methodIdentifier,
                   errMsg, ie);
             // connection freed up, so try again.
             return (getConnection());
             * You can't just make a new connection in the foreground when none are
             * available, since this can take several seconds with a slow network
             * connection. Instead, start a thread that establishes a new
             * connection, then wait. You get woken up either when the new
             * connection is established or if someone finishes with an existing
             * connection.
        private void makeBackgroundConnection() {
         connectionPending = true;
         try {
             Thread connectThread = new Thread(this);
             log.debug("background thread created");
             connectThread.start();
         } catch (OutOfMemoryError oome) {
             log.error("makeBackgroundConnection ="+ oome.getStackTrace());
             * Thread run method
        public void run() {
         String methodIdentifier = "run";
         try {
             Context connection = makeNewConnection();
             synchronized (this) {
              availableConnections.add(connection);
              connectionPending = false;
              notifyAll();
         } catch (Exception e) { // SQLException or OutOfMemory
             // Give up on new connection and wait for existing one
             // to free up.
             String errMsg = "Exception raised =" + e.getStackTrace();
             log.error(errMsg);   
             * This explicitly makes a new connection. Called in the foreground when
             * initializing the ConnectionPool, and called in the background when
             * running.
             * @return Context
             * @throws CDLookupException
        private Context makeNewConnection() throws CDLookupException {
         String methodIdentifier = "makeNewConnection";
         Context context = null;
         env = new Properties();
         log.debug("inside " + methodIdentifier);
         try {
             env.put(Context.INITIAL_CONTEXT_FACTORY,
                  getVendorContextFactoryClass());
             env.put(Context.PROVIDER_URL, getLdapServerUrl());
             env.put("com.sun.jndi.ldap.connect.pool", "true");
             context = new InitialDirContext(env);
         } catch (NamingException e) {
             String errMsg = "CDLdapBuilder connect() - failure while attempting to contact "
                  + ldapServerUrl + " Exception is " + e.toString();
             throw new CDLookupException(classIdentifier, methodIdentifier,
                  errMsg, e, LookupFailureReasons.serviceUnavailable);
         } catch (Exception e) {
             String errMsg = "CDLdapBuilder connect() - failure while attempting to contact "
                  + ldapServerUrl + " Exception is " + e.toString();
             throw new CDLookupException(classIdentifier, methodIdentifier,
                  errMsg, e, LookupFailureReasons.serviceUnavailable);
         log.info("new connection :" + (threadCount++) + " name =" + context);
         log.debug("exit " + methodIdentifier);
         return context;
             * releases connection to the free pool
             * @param context
        public synchronized void free(Context context) {
         busyConnections.remove(context);
         availableConnections.add(context);
         // Wake up threads that are waiting for a connection
         notifyAll();
             * @return int give total no of avail connections.
        public synchronized int totalConnections() {
         return (availableConnections.size() + busyConnections.size());
             * Close all the connections. Use with caution: be sure no connections
             * are in use before calling. Note that you are not <I>required</I> to
             * call this when done with a ConnectionPool, since connections are
             * guaranteed to be closed when garbage collected. But this method gives
             * more control regarding when the connections are closed.
        public synchronized void closeAllConnections() {
         closeConnections(availableConnections);
         availableConnections = new Vector();
         closeConnections(busyConnections);
         busyConnections = new Vector();
             * Close all connections existing.
             * @param connections
             *                void
        private void closeConnections(Vector connections) {
         String methodIdentifier = "closeConnections";
         try {
             for (int i = 0; i < connections.size(); i++) {
              Context context = (Context) connections.get(i);
              if (context != null) {
                  log.info(" connection name:" + context
                       + " removed. Threadcount =" + (threadCount++));
                  context.close();
                  context = null;
         } catch (NamingException e) {
             String errMsg = "CDLdapBuilder connect() - failure while attempting to contact "
                  + ldapServerUrl + " Exception is " + e.toString();
             log.error(errMsg);
        public synchronized String toString() {
         String info = "ConnectionPool(" + getLdapServerUrl() + ","
              + getVendorContextFactoryClass() + ")" + ", available="
              + availableConnections.size() + ", busy="
              + busyConnections.size() + ", max=" + maxConnections;
         return (info);
             * @return the defaultSearchBase
        public final String getDefaultSearchBase() {
         return defaultSearchBase;
             * @param defaultSearchBase
             *                the defaultSearchBase to set
        public final void setDefaultSearchBase(String defaultSearchBase) {
         this.defaultSearchBase = defaultSearchBase;
             * @return the ldapServerUrl
        public final String getLdapServerUrl() {
         return ldapServerUrl;
             * @param ldapServerUrl
             *                the ldapServerUrl to set
        public final void setLdapServerUrl(String ldapServerUrl) {
         this.ldapServerUrl = ldapServerUrl;
             * @return the vendorContextFactoryClass
        public final String getVendorContextFactoryClass() {
         return vendorContextFactoryClass;
             * @param vendorContextFactoryClass
             *                the vendorContextFactoryClass to set
        public final void setVendorContextFactoryClass(
             String vendorContextFactoryClass) {
         this.vendorContextFactoryClass = vendorContextFactoryClass;
         * @return the availableConnections
        public final Vector getAvailableConnections() {
            return availableConnections;
    }

    hi ejp
    Thx for the reply.
    // Enable connection pooling
    env.put("com.sun.jndi.ldap.connect.pool", "true");
    Is this suffice to get the connection pool working,
    Should i merely have a thread to maintain the connection with the ldap that uses sun's connection pool; or allow requestes to create new object for the connection and still this pool will hold.
    for example in the above code instead to housekeep the thread merely maintain connection with the pool
    or
    should I directly connect each object with the ldap?
    I am unable to understand how exactly sun's connection pool is working and how it should be used. I have gone thru the following example but picture is still hazy and undigestable to me.
    java.sun.com/products/jndi/tutorial/ldap/connect/pool.html
    Rgds

  • ABAP Runtime Error  (Code 14)

    Hi,
    We have SAP NetWeaver 7.0 SR2 ABAP+Java on Linux: Oracle
    I am with the following problem applying Suport Package SAPKB70014
    returns the error:
    Runtime Errors         TABLE_INVALID_INDEX
    Date and Time          26.05.2008 16:10:14
    Short text
        Error in ABAP/4 statement when processing an internal table.
    Error analysis
        When changing or deleting one or more lines of the internal table
        "\FUNCTION=TR_READ_AND_DISPLAY_LOG\DATA=LT_LINES" or when inserting in the
         table "\FUNCTION=TR_READ_AND_DISPLAY_LOG\DATA=LT_LINES", "-1" was used as
        the line index. An index less than or equal to zero is not
        allowed.
        The error can occur when using the following options:
        1. "INDEX idx" for specifying the line number in the table
         "\FUNCTION=TR_READ_AND_DISPLAY_LOG\DATA=LT_LINES"
           where you want to change, insert or delete.
        2. "FROM idx" for specifying the start index when deleting a line
           area from or inserting a line area into the table
         "\FUNCTION=TR_READ_AND_DISPLAY_LOG\DATA=LT_LINES".
        3. "TO idx" for specifying the end index when deleting a line
           area from or inserting a line area into the table
         "\FUNCTION=TR_READ_AND_DISPLAY_LOG\DATA=LT_LINES".
        At the time of the termination, the table contained 38755 lines.
    Trigger Location of Runtime Error
        Program                                 SAPLSLOG
        Include                                 LSLOGF03
        Row                                     231
        Module type                             (FORM)
        Module Name                             READ_LOG_FILE
    Source Code Extract
    219 *& -
      Output the result -
    220   IF lv_stop_index = 0.
    221 *& exception 5 : lt_lines = 0  empty log.
    222     MESSAGE i293(pu).
    223   ELSE.
    224
    225 *& reduce pt_lines to the required parts.
    226
    227 * delete block before required
    228     IF  lv_start_index <> 1 .
    229       lv_delblock1_beg  = 1 .
    230       lv_delblock1_end  = lv_start_index - 1  .
    >>>       DELETE pt_lines FROM lv_delblock1_beg   TO lv_delblock1_end  .
    232     ENDIF.
    233
    234 * delete block after required
    235     IF lv_stop_index <> lv_line_num  .
    236       lv_delblock2_beg = lv_stop_index - lv_start_index  + 2 .
    237       lv_delblock2_end = lv_line_num  - lv_start_index  +  1 .
    238
    239       DELETE pt_lines FROM lv_delblock2_beg   TO lv_delblock2_end  .
    240
    241     ENDIF .
    242
    243   ENDIF.
    244
    245
    246 ENDFORM.                               " READ_LOG_FILE
    247
    248 &----
    249 *&      Form  READ_LOG_DB
    250 &----
    Any one help me resolve this problem.
    PLS

    Hi Mikhail,
    I'd a similar problem in one project I've developed. Check the system log to see if you can debug the problem: tcode sm21.
    In my case I had to implement some SAP Notes and upgrade from SP10 to SP11.

  • LSO_PSV2 - Create /w Resources freezing, ABAP runtime error, TIME_OUT

    Hello Experts,
    I have an individual user that is a part of a team that manages our LSO environment. He is experiencing a problem when performing a "Create with resources" on an instructor-led course.
    After choosing this option his session just spins but never enters the course details screen as expected.
    After anywhere from 15 - 30min the session returns an ABAP runtime error of "TIME_OUT". The error details state that the time out for ABAP programs is set to 3000sec (50min). The odd thing is that the program never reaches the 50 min marks but still throws the error.
    The user is able to select the "create w/o resources" option and get to the next screen as expected.
    I have run security traces (ST01) on his account and all looks fine (rc=0)
    He is one of several people that executes this transaction but is the only user that is receiving this issue. The team is assigned to the same position and shares the same PD profile. They share the same security roles and the same ABAP program is being run.These users are a third party vendor that remote in via citrix desktop.
    I have had our Basis team exam the ABAP runtime error and what is happening behind the scenes as this runs and they see no indication that the program is retrieving data even though it processes for a long time.
    Obviously this is a complex issue, I have searched for two weeks with no success. Any thoughts, suggestions are more than welcome at this point as the user is unable to perform needed work functions.

    Any solution on this one? I have the same problem with LSO_PSV2 :/

  • 11/11/2014 - Release - AIR 15 Runtime and SDK

    Today we're pleased to announce that the next version of AIR is available for immediate download.  This release includes bug and security fixes.  In addition, the AIR SDK has been updated with important iOS 8 compatibility updates.
    Below are some of the key features and benefits of AIR 15.  Please see our release notes for full details.
    New Features:
    Stage3D “Standard” profile support for iOS and Android
    In the Flash Runtime 14 release we introduced the Stage3D “Standard” profile which provided many advanced 3D features.  At that time, the “Standard” profile was only available on desktop platforms.  In the AIR 15 release we are extending this coverage to mobile platforms.  If a device supports OpenGL ES3, it can successfully request the “Standard” profile and use the same advanced features as the desktop platform.
    For additional information, please see our Stage3D Standard Profile article.
    Relaxing Stage3D Render Target Clear
    In previous versions of Stage3D, after switching the render texture through Context3D::setRenderToTexture, you were required to clear it before drawing. In this release, we're removing this limitation and optimizing the use of render textures. This change will allow you to further optimize and reuse depth and stencil buffers between different render textures.  
    For additional information, please see Relaxing Render Target Clear Operation in Stage 3D.
    StageText.drawViewPortToBitmapData now supports Retina displays
    Currently, AIR will allow a bitmap with the same width/height of the StageText object to be passed into drawViewPortToBitmapData.  While fine for standard resolution displays, this is not sufficient for Apple's Retina HiDPI displays.  Based on customer feedback, we've altered the drawViewPortToBitmapData method to accept a doubled size BitmapData with StageText's view port on a Mac Retina display, and then draw a HiDPI image from the view port.
    Improved Packaging Engine is now default - iOS
    Starting AIR 15, new improved IPA packaging engine is now the default packaging mode when packaging for AOT targets ipa-app-store, ipa-test, ipa-ad-hoc and ipa-debug. If you encounter any packaging or runtime issues, please report at http://bugbase.adobe.com. To use older packaging mode, use "-useLegacyAOT yes" in the ADT command, before the signing options. To learn more about the feature, please read Faster Compiling with AIR for iOS
    AIR Gamepad Enhancements
    AIR Gamepad feature enables the app developers to provide a second screen on Android mobile devices for the Flash based browser games. AIR Gamepad API enables Flash based browser apps to connect to a paired Android device running the AIR Runtime app and therefore allowing the Android devices to be used as game controllers or second-screen interfaces. Following enhancements are available starting AIR 15.
    Multiplayer Support
    Gyroscope Events
    Magnetometer Events
    Applying skin as AIR gamepad screen
    To learn more about the feature and usage guidelines, please see Android Devices with AIR as Gamepads
    AIR Cross Promotion
    Adobe AIR 15 now supports cross promotion of AIR games for mobile devices. Cross promotions can be effective in saving some amount of advertising cost. With the right partnership, you gain access to a wider customer base with a demographic similar to that of your application. This cross promotion is free and works on a credit system. All you need is to earn enough credit points by promoting other AIR games to begin your own promotion campaign. The AIR SDK offers the new AdViewer API for promotion campaigns as a SWC, it provides functions to load and show in-game advertisements. You earn credit points for promoting AIR games by other developers based on ad impressions and clicks.
    To learn more about the feature and usage guidelines, please see Cross Promotion of AIR Games for Mobile.
    Fixed Issues:
    [iOS] Launch image [email protected] is not appearing in iPhone 6 Plus in standard display mode (Bug 3837220)
    [iOS] "Unknown or unsupported SDK version" error appears on installing application on iOS simulator, when -platformsdk version is given as .../Developer/SDK/iPhoneSimulator.sdk. (Bug 3837285)
    [iOS] [New fast packager]Hurlant Base64 encode doesn't work in new fast compiled packaging mode. (Bug 3832978)
    [iOS] Adobe Air Runtime initiates the wrong launch image ([email protected]), when [email protected] and [email protected] images are packaged. (Bug 3832184)
    [iOS] Blank frame appears instead of launch image [email protected] when [email protected], [email protected] and [email protected] are packaged with the application. (Bug 3829428)
    [iOS] [New fast packager] Some performance fixes are done for increasing fps values. (Bug 3815079).
    [Android 5.0] Stage3D fails to create context on Android 5.0. (Bug 3841657)
    Multiple security and stability fixes
    Known Issues:
    [Android] StageText not visible after screen rotation. (Bug 3821523).
    [iPhone 6 Plus][RADAR] Wrong screen size and dpi is returned through the runtime APIs. (Bug 3829474)
    [iPhone 6 Plus]
    [iOS] iPad Launch image is displayed on iPhone 6 Plus in standard display mode. (Bug 3836781)
    [iOS]Unable to install the application on iOS Simulator after updating iOS SDK and iPhone simulator with 7.1. (Bug 3833912)
    [iOS] [New fast packager] Some applications compiled with older ActionScript compiler won’t work with new fast packaging engine but when rebuild again with latest ActionScript compiler apps work fine. (Bug 3837665)
    Download Locations:
    AIR 15 runtime for Windows: 15.0.0.356 Runtime Download
    AIR 15 runtime for Macintosh: 15.0.0.356 Runtime Download
    AIR 15 SDK & Compiler for Windows: 15.0.0.356 SDK & Compiler Download
    AIR 15 SDK & Compiler for Macintosh: 15.0.0.356 SDK & Compiler Download
    Note: To provide all the all the necessary tools for our developers in one place and avoid having to download multiple components, we are packaging Adobe AIR 15 SDK and ActionScript Compiler 2.0 in a single SDK called “Adobe AIR 15 SDK & Compiler”.
    AIR SDK 15 (Compatible with Flex) for Windows: 15.0.0.356 SDK Windows Download
    AIR SDK 15 (Compatible with Flex) for Macintosh: 15.0.0.356 SDK Macintosh Download
    Previous versions of the AIR runtime and SDK can be found on the Archived AIR SDK and Runtimes page

    Hi Colin,
    Thanks for the response!
    I started pointing to SDKs back when ANE support first came out and it was required to point to the OS5.1 sdk in order to get ANEs to work.
    I had been specifying the sdk ever since, since it had been working for me, even though it was no longer needed.
    I just tried removing that and letting AIR take care of using the right SDK and it seems to have solved my screen rotation issue!
    Thank you so much for that!
    I do have a lot of splash screens. Again I think this was left over from when I started using AIR back in 2011. At that point in order to get the splash screens working correctly I ended up having to add all the different versions. However, I'd love to get rid of most of them as they bloat my app size. I'll try removing most of them and do some testing to ensure everything works fine now without them. Although I suspect I should still also need the Default@2x~ipad.png
    Thanks again for your help!
    Craig.

Maybe you are looking for

  • (My post isn't showing up?) Sound effect muffles/is louder than the other audio layers

    I want to point out that the last time I posted this, the discussion was completely blank. This is a repost and hopefully it won't be blank this time In my most recent short movie, I decided that I would focus a lot more on sound than I normally do,

  • My ipod touch wont play through my docking station

    hiya i have an ipod touch. aout a week ago it stopped working with my docking station. it wont play through the docking station speakers. ive tried two other ipods on the station and they work fine so its clearly a problem with my ipod. the ipod regi

  • My ratings disappeared when I turned On iTunes Match

    Hi there. I've spent a great deal of time organizing and meticulosely rating songs in my playlists since a couple of years, recently with iTunes Match, all of my precious ratings dissapeared from many playlists, when I 'Turn On' iTunes Match, the rat

  • Is Lightroom 5 & CS6?

    Is Ligtroom 5 compatible with CS6 or will it be necessary to join the cloud and upgrade to the new Photoshop Cloud?

  • XML Data from Relational Tables

    Hi, My requirement is to pull data from relational tables into xml format and port it to the user (either as a file or allow the user to access it directly from their browser). What is the best way to accomplish this. Your suggestions are appreciated