Performance overhead of calling Thread.currentThread().getStackTrace()

All I can see is it is calling native function
private static native StackTraceElement[][] dumpThreads(Thread athread[]);
Just wonder if I call this method for every transaction, will this causing performance issue? Is this method considered slow to execute?

How about compare with String concat?
We now having our own transaction framework, at the end of the transaction the module call transaction.start() must call either commit() / close() . If that module doesn't do that, next module cannot start() another transaction. I understand this is not a good design, but this is what this is and I am not the module owner so I can say nothing about that.
However, I would still like to have some checking to see if any the transaction starter forget to commit / close the transaction. I just thought of in method start() I save a copy of stacktrace() element. If the transaction cannot start then I show the printStack() of last saved copy so that I know which module have that problem.
How do you think about that?

Similar Messages

  • 10 ms overhead when calling Thread.sleep on Linux

    Hi,
    I have been working on a traffic shaping simulation that requires me to send packets on a ms basis. When I call Thread.sleep(11) on Linux 2.4, I get a constant return around 30 ms. I tried to bypass the Thread.sleep function and called directly the select() function under linux with a timeout of 11 ms then I get a constant return around 20 ms. Then if I create a test.c program that loop 100 times calling the select(11), I get a very accurate rate around 10-11 ms. Anyone knows where that 10 ms overhead comes from? I tried executing the java program with Thread.sleep and the -XX:ForceTimeHighResolution but it doesn;t seem to change anything ! Any info would be very welcome ! Thanks

    Actually I get this behavior only on a machine with kernel 2.4. On a different machine with kernel 2.6 I get an accuracy of 10ms for a select call with 10 ms timeout. I know there was some improvements on the jiffy for kernel2.6 but I still don't get why calling select timeout 10ms from a C program return an accuracy of 10ms on linux 2.4 and the same select() timeout 10ms called from java return an accuracy of only 20 ms on kernel 2.4..... :( still looking

  • Platform.runLater messes up my Thread.currentThread().getContextClassLoader()

    Hi,
    I have a plugin mechanism in my application. The plugins are defines by an interface and are loaded via URLClassLoader. A plugin can also have resources, loaded via ResourceBundle.getBundle.
    Whenever a plugin's method is called, I do this, before it is called:
    ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(pluginClassLoaders.get(pluginClass.cast(proxy)));
    // Invoke plugin method
    Thread.currentThread().setContextClassLoader(oldLoader);
    The plugin methods are called in their own thread, that means, when I want to open a window I need to do it on the JavaFX Application Thread with Platform.runLater.
    The problem is, that in the run method of the Platform.runLater, my Thread.currentThread().getContextClassLoader() is not my URLClassLoader but the Application Classloader.
    Why I need this?
    I don't want the plugin developer to always keep in mind, that he has to pass the correct class loader (of his classes) into the ResourceBundle.getBundle method.
    Instead I thought I could rely on Thread.currentThread().getContextClassLoader(), which is set in the main application, to load the correct bundle.
    It would work, but not if I load the bundle inside the JavaFX Application Thread (but which makes the most sense for UI development).
    So my goal was to have a convenient method like:
    String getResource(String bundle, String key)
    return ResourceBundle.getBundle(bundle).getString(key),  Thread.currentThread().getContextClassLoader());
    To avoid passing the classloader every time.
    Any ideas on this?

    OK, found the problem.
    In data-sources.xml, there is a connection pool and a managed-data-source settings. If I set the data source in there - it works!! Seems these XML tags take preference above the datasource tag.
    This is how the data-sources.xml now looks that's been working:
    <?xml version = '1.0' standalone = 'yes'?>
    <data-sources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/data-sources-10_1.xsd" schema-major-version="10" schema-minor-version="1">
    <connection-pool name="jdev-connection-pool-MYDB">
    <connection-factory factory-class="com.mysql.jdbc.Driver" user="henkie" password="->DataBase_User_recGxQcVfghwCszzy_gfsRgwOrxutL2l" url="jdbc:mysql://localhost/mydb"/>
    </connection-pool>
    <managed-data-source name="jdev-connection-managed-MYDB" jndi-name="jdbc/MYDBDS" connection-pool-name="jdev-connection-pool-MYDB"/>
    </data-sources>

  • Thread safety bug in XPS Serializer or FixedDocument sequence? "calling thread cannot access this object..."

    Every once in a while (500 iterations or more) I'm getting an exception in the static method below stating "calling thread cannot access this object because a different thread owns it".  Thing is, this method references no external objects
    and performs no special threading operations.  All of the WPF objects are created and consumed in this method.  The only aspect that is multi-threaded is that this method can get called concurrently on different threads in the same app domain (the
    project is a Windows service). That said the fileToDecollate parameter will be unique every time, so there is no "collision" as far as that goes.
    Any ideas?   This is maddening and in theory it should not be possible to blow this error.
    Exception Information------------------------------------------
    System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.
       at System.Windows.Threading.Dispatcher.VerifyAccess()
       at System.Windows.DependencyObject.GetLocalValueEnumerator()
       at System.Windows.Xps.Serialization.SerializersCacheManager.GetTypeDependencyPropertiesCacheItem(Object serializableObject)
       at System.Windows.Xps.Serialization.SerializersCacheManager.GetSerializableDependencyProperties(Object serializableObject)
       at System.Windows.Xps.Serialization.SerializablePropertyCollection.InitializeSerializableDependencyProperties()
       at System.Windows.Xps.Serialization.SerializablePropertyCollection.Initialize(PackageSerializationManager serializationManager, Object targetObject)
       at System.Windows.Xps.Serialization.SerializableObjectContext.CreateContext(PackageSerializationManager serializationManager, Object serializableObject, SerializableObjectContext serializableObjectParentContext, SerializablePropertyContext serializablePropertyContext)
       at System.Windows.Xps.Serialization.ReachSerializer.DiscoverObjectData(Object serializedObject, SerializablePropertyContext serializedProperty)
       at System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(Object serializedObject)
       at System.Windows.Xps.Serialization.FixedDocumentSerializer.SerializeObject(Object serializedObject)
       at System.Windows.Xps.Serialization.ReachDocumentReferenceSerializer.PersistObjectData(SerializableObjectContext serializableObjectContext)
       at System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(Object serializedObject)
       at System.Windows.Xps.Serialization.ReachDocumentReferenceCollectionSerializer.SerializeDocumentReference(Object documentReference)
       at System.Windows.Xps.Serialization.ReachDocumentReferenceCollectionSerializer.SerializeDocumentReferences(SerializableObjectContext serializableObjectContext)
       at System.Windows.Xps.Serialization.ReachDocumentReferenceCollectionSerializer.PersistObjectData(SerializableObjectContext serializableObjectContext)
       at System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(SerializablePropertyContext serializedProperty)
       at System.Windows.Xps.Serialization.ReachSerializer.SerializeProperty(SerializablePropertyContext serializablePropertyContext)
       at System.Windows.Xps.Serialization.ReachSerializer.SerializeProperties(SerializableObjectContext serializableObjectContext)
       at System.Windows.Xps.Serialization.ReachSerializer.SerializeObjectCore(SerializableObjectContext serializableObjectContext)
       at System.Windows.Xps.Serialization.DocumentSequenceSerializer.PersistObjectData(SerializableObjectContext serializableObjectContext)
       at System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(Object serializedObject)
       at System.Windows.Xps.Serialization.XpsSerializationManager.SaveAsXaml(Object serializedObject)
       at System.Windows.Xps.XpsDocumentWriter.SaveAsXaml(Object serializedObject, Boolean isSync)
       at System.Windows.Xps.XpsDocumentWriter.Write(FixedDocumentSequence fixedDocumentSequence)
       at MyCompany.Utilities.Document.XPSDocument.Decollate(String fileToDecollate, String outputPath) in E:\Projects\MyCompany\Utilities\MyCompany.Utilities.Document\XPSDocument.cs:line 358
       at MyCompany.Services.ERM.XPSCapture.Decollate(String fileToDecollate, String outputPath) in E:\Projects\MyCompany\Services\MyCompany.Services.ERM\XPSCapture.cs:line 210
       at MyCompany.Services.ERM.ERMFileProcessor.decollateERMFile(String tempERMFile, IFileCapture fileCapture) in E:\Projects\MyCompany\Services\MyCompany.Services.ERM\ERMFileProcessor.cs:line 1257
       at MyCompany.Services.ERM.ERMFileProcessor.process() in E:\Projects\doc-link\MyCompany\Services\Altec.Services.ERM\ERMFileProcessor.cs:line 354
       at MyCompany.Services.ERM.ERMFileProcessor.Process(ProcessingCompleteCallback callback) in E:\Projects\MyCompany\Services\MyCompany.Services.ERM\ERMFileProcessor.cs:line 90
    Additonal Info------------------------------------------
    ExceptionManager.MachineName: BTP-30-DEV
    ExceptionManager.WindowsIdentity: XXXXX-WA\Bradley
    ExceptionManager.FullName: WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    ExceptionManager.AppDomainName: MyCompany.XXXXXXServiceHost.exe
    ExceptionManager.ProcessInfo: PID=7392, ThreadID=7816, Managed ThreadID=36, Name=MyCompany.XXXXXXServiceHost, Uptime=00:02:12.2548416
    ExceptionManager.ProcessResourceUsage: Working Set=265188 KB, Peak Working Set=525940 KB, Virtual Memory Size=530264 KB, Peak VM Size=809832 KB, Handles=631
    ExceptionManager.SystemMemory: Load=81%, Total Physical=3168748 KB, Free Physical=586736 KB, Total PageFile=5213700
    publicstaticList<string>
    Decollate(stringfileToDecollate,
    stringoutputPath)
      // iterate fixed documents and fixed pages, create new XPS files
    List<string>
    xpsDecFiles = newList<string>();
      using(XpsDocumentxpsSourceDocument
    = newXpsDocument(fileToDecollate,
    FileAccess.Read))
        FixedDocumentSequencefixedDocSeq
    = xpsSourceDocument.GetFixedDocumentSequence();
        intpageNumber = 0;
        foreach(DocumentReferencedocReference
    infixedDocSeq.References)
          FixedDocumentsourceFixedDoc
    = docReference.GetDocument(false);
          foreach(PageContentpage
    insourceFixedDoc.Pages)
            pageNumber++;
            // prepare new fixed doc sequence
    FixedDocumentSequencenewFixedDocSeq
    = new
    FixedDocumentSequence();
    DocumentReferencenewDocReference
    = new
    DocumentReference();
    FixedDocumentnewFdoc
    = new
    FixedDocument();
    newDocReference.SetDocument(newFdoc);
    // copy the page
    PageContentnewPage =
    new
    PageContent();
    newPage.Source = page.Source;
    (newPage asIUriContext).BaseUri
    = ((IUriContext)page).BaseUri;
    // tickle this method... presumably just to load the FixedPage data.
    FixedPagenewFixedPage
    = newPage.GetPageRoot(false);
    // Add page to fixed doc sequence.
    newFdoc.Pages.Add(newPage);
    // Always do this last: add document reference to fixed doc sequence. 
    newFixedDocSeq.References.Add(newDocReference);
    // create and save new XPS doc                   
    stringdecFileName =
    Path.Combine(outputPath,
    Path.GetFileNameWithoutExtension(fileToDecollate)
    + "~"+ (pageNumber).ToString()
    + FileExtensions.XPS);
    if(File.Exists(decFileName))
    File.Delete(decFileName);
    XpsDocumentnewXPSDoc
    = new
    XpsDocument(decFileName,
    FileAccess.ReadWrite);
    // testing.  thread IDs should be the same.
    //Debug.Assert(System.Windows.Threading.Dispatcher.CurrentDispatcher.Thread.ManagedThreadId == newFixedDocSeq.Dispatcher.Thread.ManagedThreadId);
    XpsDocument.CreateXpsDocumentWriter(newXPSDoc).Write(newFixedDocSeq);
    newXPSDoc.Close();
    // add file to list
    xpsDecFiles.Add(decFileName);
      returnxpsDecFiles;

    I have opened a support case with Microsoft through my employer.  I'm convinced there is some .NET framework code that is not thread safe.  I did put together a test harness app that demonstrates the problem (within 30 seconds or so after
    you start it) and I sent that to MS support.  They're looking into it. Anyone else who is curious can download the sample project here:
    https://skydrive.live.com/redir?resid=5CBB4B55BCCB2D67!443&authkey=!AGEnR3CKrXUU6E0
    Bradley
    Bradley P.

  • Using Thread.currentthread.sleep but not delaying appropriately

    Ok, here it goes. Im currently using the thread.sleep method to delay the changing of the text within some labels. I have 3 labels which represent some arrays. I then sort the arrays. Im trying to throw a delay in so that the user can see the changes happen to the array. Although, when I call the wait.millisec(1000) in (the sleep function I threw into its own wait class) it seems that the waiting all happens at the end. I dont see it during the loop to show the arrangement changes within the arrays. I stepped through the code using the debugger, but it doesnt seem to help.
    Look in the buttonListener within the FourX class.
    * SortTest.java                                   Author:Tim Dudek
       This trivial program tests the insertion sort and selection sort
       subroutines.  The data is then shown graphically.
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    public class SortTest {
       final static int ARRAY_SIZE = 10;  // Number of items in arrays to be sorted.
                                            // (This has to be 10 or more.)
       public static int[] A, B;
       public static JLabel lblOrig, lblSS, lblIS;
       public static void main(String[] args) {
            JFrame frame = new JFrame ("Tim Dudek");
              frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
              FourX display = new FourX();//create the main panel
              frame.setSize(450, 320);
              frame.getContentPane().add(display);
              frame.setVisible(true);  
          A = new int[ARRAY_SIZE];     // Make an array  ints
          for (int i = 0; i < A.length; i++){      // Fill array A with random ints.
             A[i] = (int)(100*Math.random());
             lblOrig.setText(lblOrig.getText() + " "     + A);
    lblIS.setText(lblIS.getText() + " "     + A[i]);
    lblSS.setText(lblSS.getText() + " "     + A[i]);
    B = (int[])A.clone(); // make B an exact copy of A.
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    public class FourX extends JPanel {
         static final long serialVersionUID = 1L; //eclipse echo problem
         private JLabel lblO, lblI, lblS;
         private JButton sort;
         public FourX(){//JLabel lblOrig,JLabel lblSS, JLabel lblIS){
              setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
              SortTest.lblSS = new JLabel ("");
              SortTest.lblOrig = new JLabel ("");
              SortTest.lblIS = new JLabel ("");
              lblO = new JLabel("Orginal", JTextField.LEFT);
              lblI = new JLabel("Insertion Sort", JTextField.LEFT);
              lblS = new JLabel("Selection Sort", JTextField.LEFT);
              sort = new JButton("Sort");     
              sort.addActionListener(new buttonListener());
              SortTest.lblSS.setFont(new Font("Arial", Font.BOLD, 30));
              SortTest.lblSS.setHorizontalAlignment(JTextField.CENTER);
              SortTest.lblSS.setBorder(BorderFactory.createLineBorder (Color.RED, 3));
              SortTest.lblIS.setFont(new Font("Arial", Font.BOLD, 30));
              SortTest.lblIS.setHorizontalAlignment(JTextField.CENTER);
              SortTest.lblIS.setBorder(BorderFactory.createLineBorder (Color.BLUE, 3));
              SortTest.lblOrig.setFont(new Font("Arial", Font.BOLD, 30));
              SortTest.lblOrig.setHorizontalAlignment(JTextField.CENTER);
              SortTest.lblOrig.setBorder(BorderFactory.createLineBorder (Color.BLACK, 3));
              add(Box.createRigidArea(new Dimension (10, 10)));
              add(lblO);
              add(SortTest.lblOrig);
              add(Box.createRigidArea(new Dimension (10, 10)));
              add(lblS);
              add(SortTest.lblSS);
              add(Box.createRigidArea(new Dimension (10, 10)));
              add(lblI);
              add(SortTest.lblIS);
              add(Box.createRigidArea(new Dimension (10, 10)));
              add(sort);
         private class buttonListener implements ActionListener{
              public void actionPerformed (ActionEvent event){
              // sort A into increasing order, using selection sort
                   for (int lastPlace = SortTest.A.length-1; lastPlace > 0; lastPlace--) {
                        Wait.milliSec(50);
                   //Find the largest item among A[0], A[1], ... A[lastPlace],
              // and move it into position lastPlace by swapping it with
              // the number that is currently in position lastPlace
                        int maxLoc = 0; // location of largest item seen so far
                   for (int j = 1; j <= lastPlace; j++) {
                        if (SortTest.A[j] > SortTest.A[maxLoc])
                   maxLoc = j; // Now, location j contains the largest item seen
                   int temp = SortTest.A[maxLoc]; // swap largest item with A[lastPlace]
                   SortTest.A[maxLoc] = SortTest.A[lastPlace];
                   SortTest.A[lastPlace] = temp;
                   Wait.milliSec(100);//<------------ waiting???>
                   SortTest.lblSS.setText("");
                   for (int i = 0; i < SortTest.A.length; i++){
                        SortTest.lblSS.setText(SortTest.lblSS.getText() + " "     + SortTest.A[i]);
                   Wait.oneSec();//<------------ waiting???>
                   // sort the array A into increasing order
                   int itemsSorted; // number of items that have been sorted so far
                   for (itemsSorted = 1; itemsSorted < SortTest.B.length; itemsSorted++) {
                        // assume that items A[0], A[1], ... A[itemsSorted-1] have
                        // already been sorted, and insert A[itemsSorted] into the list.
                        int temp = SortTest.B[itemsSorted]; // the item to be inserted
                        int loc = itemsSorted - 1;
                        while (loc >= 0 && SortTest.B[loc] > temp) {
                             SortTest.B[loc + 1] = SortTest.B[loc];
                             loc = loc - 1;
                        SortTest.B[loc + 1] = temp;
                        Wait.milliSec(100);//<------------ waiting???>                    SortTest.lblIS.setText("");
                        for (int i = 0; i < SortTest.B.length; i++){
                             SortTest.lblIS.setText(SortTest.lblIS.getText() + " "     + SortTest.B[i]);
    public class Wait {
         public static void oneSec() {
              try {
                   Thread.currentThread().sleep(1000);
              catch (InterruptedException e) {
                   e.printStackTrace();
         public static void milliSec(long s) {
              try {
                   Thread.currentThread().sleep(s);
              catch (InterruptedException e) {
                   e.printStackTrace();

    Wow, ok. this is extrodinarily confusing. I read the tutorials, but they're not easy to follow.
    So, what I did was at the entry point:
    public class SortTest implements Runnable {
       final static int ARRAY_SIZE = 10;  // Number of items in arrays to be sorted.
                                            // (This has to be 10 or more.)
       public static int[] A, B;
       public static JLabel lblOrig, lblSS, lblIS;
       public static void main(String[] args) {
            (new Thread(new SortTest())).start();
       public void run(){
            JFrame frame = new JFrame ("Tim Dudek");
              frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
              FourX display = new FourX();//create the main panel
              frame.setSize(450, 320);
              frame.getContentPane().add(display);
              frame.setVisible(true);  
          A = new int[ARRAY_SIZE];     // Make an array  ints
          for (int i = 0; i < A.length; i++){      // Fill array A with random ints.
             A[i] = (int)(100*Math.random());
             lblOrig.setText(lblOrig.getText() + " "     + A);
    lblIS.setText(lblIS.getText() + " "     + A[i]);
    lblSS.setText(lblSS.getText() + " "     + A[i]);
    B = (int[])A.clone(); // make B an exact copy of A.
    Ok, as I understand, this creates the initial thread to build the gui. Now you suggest that when the user hits "sort" that a second thread be created to handle the sorting routine.  From what I understand I can only inherit from one class in java.  My buttonListener already implements ActionListener. I obviously cant implement ActionListener and Runnable.  Do you have a suggestion? Maybe a link to an example?
    I'm pretty lost. 
    Tim                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Thread.currentThread() ); Meaning

    Does anyone know what the output I'm getting from the currentThread method means?
    What do the int(s) represent? I've checked the API, it doesn't go into detail about
    the return.
    Method Detail
    currentThread
    public static Thread currentThread()
        Returns a reference to the currently executing thread object.
        Returns:
            the currently executing thread.And here's what I'm doing :
    System.out.println("currentThread output : " + Thread.currentThread() );
    //OUTPUT
    Thread[Thread-1,5,main]Edited by: rico16135 on May 3, 2008 1:17 PM

    It's all there in the docs.
    Read Thread.currentThread's docs. It returns a reference to the Thread object for the currently running thread.
    System.out.println calls toString, so look at Thread's toString method.
    Also look at Thread's constructors.

  • URG & IMP: How does one stop the Thread.currentThread?

    hi,
    I want to stop the current thread.
    Presently teh code used Thread.currentThread.stop()
    However stop() has been deprecated
    Thread.currentThread.interrupt() doesnot seem to help.
    If I try Thread.currentThread.isAlive() post tehinterrupt, it doesnot work as desired and teh thread is still active...
    Any pointers????
    We have alreday tried using the boolean volatile varible to stop the thread as recommended by sun and since this is the currentThread, it cannot be assigned to null.
    Thanks
    Priya

    hi,
    I want to stop the current thread.
    Presently teh code used Thread.currentThread.stop()Whyever would a thread want to deliver a stop() to itself.
    Did you mean that you wanted to stop() a different thread?
    As indicated in the (depreaction) documentation for stop(), using interrupt()
    is a better idea. However, that requires you to have a protocol
    where the receiver of the interrupt then reacts in an appropriate
    manner, i.e. interrupt() can be the basis for cooperative
    thread termination; it can't merely replace a stop() call
    in an existing application without any other changes.
    >
    However stop() has been deprecated
    Thread.currentThread.interrupt() doesnot seem to
    help.
    If I try Thread.currentThread.isAlive() post
    tehinterrupt, it doesnot work as desired and teh
    thread is still active...
    Any pointers????
    We have alreday tried using the boolean volatile
    varible to stop the thread as recommended by sun and
    since this is the currentThread, it cannot be
    assigned to null.Think about what you are trying to achieve. Did you want
    to just do a Throw() out of the current method, with (or
    without )a corresponding Catch() in some outer context)
    so that the you can unwind in case of an exceptional
    condition and have the thread exit?
    >
    Thanks
    Priya

  • Thread.currentThread() unique for each server request?

    Hello
    I have a hosted application in glassfish. When there is a http request I write a file to disk in server machine.
    I am just wondering in writer.class can I use Thread.currentThread() as a unique identification for each and every request?
    Thank you

    I am sorry. I made the question wired by adding unnessasary things.
    Let me ask it simple, can I replace the singleton class IDpool with a class with a static variable id. like following
    IDpool class (singleton and map<thread, id>)
    public class IdPool {
        protected static IdPool pool = null;
        protected static Map<Thread,Long> idmap = new HashMap<Thread,Long>();
        public static Map<Thread,Long> getIdMap()
            return idmap;
        public static IdPool getSingleInstance()
            if(IdPool.pool==null)
                IdPool.pool = new IdPool();
            return IdPool.pool;
        public synchronized Long makeNewId(Thread thread)
            Long id =  Calendar.getInstance().getTimeInMillis();
            IdPool.idmap.put(thread,id);
            return id;
        public synchronized Long getId(Thread thread)
            return IdPool.idmap.get(thread);
    }replace above with following
    class IDClass
       public static long ID;
    }In request handler class
    // make new id
    IDClass.ID = 123;In FileWriter.class
    // get ID
    long id = IDClass.ID;Because for each and every request it starting as a new application. Application means calling for the backend Request handler and file writer program I have made. Those are in a seperate jar file.The same instance of the application never used by two request. And once the request is finished application initialize for that particular request close down.
    EJP, thank you very much for your kind attention for this matter.

  • Public static Thread currentThread() and multi core processors??

    Hello,
    I have the following basic question: what does public static Thread currentThread() mean in the context of multi core processors where several threads may execute concurrently?
    Any clue welcome,
    J.

    Hi balteo,
    When you invoke Thread.currentThread(), you get the reference of the current thread : the thread where you make the call.
    Just try :
    System.out.println("My program is running thread : " + Thread.currentThread().getName());
    mean in the context of multi core processors where several threads may execute concurrently?Several threads may run concurrently with single core processors. The number of concurrent threads you may execute depends of the processors architecture and the OS.

  • Insert, search, delete performance overhead for different collections

    Hi,
    I am trying to create a table which compares performance overheads for different collections data structures. Does anyone want to help me out? I want to put a number from 1 - 9 in each of the question marks. 1 being very poor performance and 9 being very good performance (the reason I am doing this is that I had this question in a job interview test and I didn't pass it)
    anyone have any comments?
              Searching     Inserting     Deleting     
    ArrayList ? ? ?
    LinkedList ? ? ?
    TreeSet ? ? ?
    TreeMap ? ? ?
    HashMap ? ? ?
    HashSet ? ? ?
    Stack ? ? ?

    sorry the formatting has screwed up a bit when I posted it. It should have a list of the collection types and three columns (inserting, deleting, searching)

  • Thread.currentThread().getContextClassLoader().getResourceAsStream() bug?

    Hello
    I have a problem with Thread.currentThread().getContextClassLoader().getResourceAsStream() sporadically returning null when my app is running via JNLP using Win XP/build 1.6.0_20-b02 and tomcat 6-20/JnlpDownLoadServlet.
    The code is:
    final InputStream resourceStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);I have added a map that counts the number of non null streams returned by getResourceAsStream. Here is the output when running with tracing level 5:
    cache: Reading Signers from 1024 http://x.x.x.x:8080/MDA/webstart/VTSDBClient-SOK.jar | C:\Users\xxx\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\61\6b90d63d-4feb6af0-1.7-SNAPSHOT-.idx
    cache:  Read manifest for http://10.10.20.64:8080/MDA/webstart/VTSDBClient-SOK.jar: read=117 full=14269
    cache: Reading Signers from 1024 http://x.x.x.x:8080/MDA/webstart/VTSDBClient-SOK.jar | C:\Users\xxx\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\61\6b90d63d-4feb6af0-1.7-SNAPSHOT-.idx
    Weird! data/eez-de.shp has been loaded 77 time(s) previously but is now null
    Loader is com.sun.jnlp.JNLPClassLoaderSo getResourceAsStream managed to open the file 77 times before it suddenly returns null.
    From the trace it looks like it happens when the cache is doing " Reading Signers from 1024 ..." the second time for VTSDBClient-SOK.jar. Could it be related to bug 6911763 (http://bugs.sun.com/view_bug.do?bug_id=6911763)?
    What causes the cache to reread the Signers in general and is there a way to provoke it?
    Thanks
    Carsten

    Just a tad more info on this.
    Each time Thread.currentThread().getContextClassLoader().getResourceAsStream() returns null there is a:
    network: SyncFileAccess.openLock: handled OverlappingFileLockException, remainint TO : 10000in the log.
    My does does spawn multiple threads that accesses different resources located in the same jar file in the client. Could it be a problem with using Thread.currentThread().getContextClassLoader().getResourceAsStream() from multiple threads and a slow respose from the JNLPDownLoadServlet and some locking scheme used by the JNLP cache?
    cache: Reading Signers from 1024 http://x:8080/MDA/webstart/aislayer.jar | C:\Users\x\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\52\5e675934-678dbaa9-1.5-SNAPSHOT-.idx
    BinaryFile: trying to figure out how to handle [3] data/eez-dk.shp
    cache: Reading Signers from 1024 http://x:8080/MDA/webstart/aislayer.jar | C:\Users\x\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\52\5e675934-678dbaa9-1.5-SNAPSHOT-.idx
    BinaryFile: trying to figure out how to handle [3] data/eez-se.shp
    cache: Reading Signers from 1024 http://x:8080/MDA/webstart/aislayer.jar | C:\Users\x\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\52\5e675934-678dbaa9-1.5-SNAPSHOT-.idx
    BinaryFile: trying to figure out how to handle [3] data/12nm.shp
    cache: Reading Signers from 1024 http://x:8080/MDA/webstart/aislayer.jar | C:\Users\x\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\52\5e675934-678dbaa9-1.5-SNAPSHOT-.idx
    BinaryFile: trying to figure out how to handle [3] data/eez-pl.shp
    cache: Reading Signers from 1024 http://x:8080/MDA/webstart/aislayer.jar | C:\Users\x\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\52\5e675934-678dbaa9-1.5-SNAPSHOT-.idx
    BinaryFile: trying to figure out how to handle [3] data/danm_nav.shp
    BinaryFile: trying to figure out how to handle [3] data/europ_nav.shp
    BinaryFile: trying to figure out how to handle [3] data/eez-de.shp
    network: SyncFileAccess.openLock: handled OverlappingFileLockException, remainint TO : 10000

  • Performance problem using multi-thread

    I am using berkeley db to store a int/double pair, and i randomly get 100,0000 results to check the performance . Using 1 thread, it cost about 1 Mins. But using 4 threads, it costs 4 Mins. More threads, lower performance. Is there Anyone know the reason?
    Env flags:
    envFlags=DB_CREATE | DB_INIT_MPOOL | DB_THREAD | DB_PRIVATE|DB_INIT_CDB;
    DB open flags: DB_THREAD
    and i use db->get method to get results.

    Berkeley DB 4.8 will be released soon and has features that address CMP/SMP scalability. We would appreciate your feedback on your experiences with it. Once available, please test it and post your results here, I'm sure you'll be pleasently surprised.
    regards,
    -greg

  • Performance overhead

    Hi,
    I have a quick question.
    There is part in the project where we need to update information in SAP which we gather from the user. I am getting a series of name from user and updating it. For that I am using insert statement. If user tries modify those series of name, I do delete first and insert again.
    I am not sure whether it is a good way. Also my concern is whether there will be performance overhead for SAP through my way?
    thanks.
    - deepan

    Deepan,
    Your method is fine.  No performance issue to be concerned about.
    You could also just use the MODIFY verb.
    It handles INSERT-ing and UPDATE-ing all in one statement.
    By that - I mean:
    If "Jake" does not exist in the table, it will be INSERT automatically.
    If "Jake" does exist in the table and you changing something about Jake's info, it will be UPDATEd automatically.
    All by using the MODIFY verb.

  • Does a reentrant dll call monopolize the calling thread?

    If I understand thing correctly, threading for a dll call is the same as threading for a vi whose execution priority is set to subroutine.
    To review threading in subvis:
    (1) the thread in which a subroutine-execution-priorty-vi call is made is monopolized by the subroutine-execution-priorty-vi since labview cannot time slice the thread.
    (2) if the subroutine-execution-priority-vi is not reentrant, then other threads that call the vi may be suspended because they are competing for the same code resource.
    (3) if the subroutine-execution-priority-vi is reentrant, then other threads may call the vi simultaneously. However, within any particular thread the vi must complete because of point (1).
    In
    sum, the OS timeslices between the threads, and labVIEW timeslices within the threads. If a vi's execution priority is set to subroutine, then the thread under which it is running is monopolized by the vi. Yes?
    A reentrant dll call would be equivalent to a reentrant subvi call in which the subvi's execution priority is set to subroutine. Yes?
    If the above is correct then this should also be correct:
    Using an API call to return the thread ID, you could use the the thread ID at the front and back side of a dll call, as well as in a message library function callable from a dll, to theoretically message labVIEW upon the dll return. The message would be uniquely identifiable because a dll call cannot be superceded by another dll call from within the same thread. Yes?
    I'm not saying that it would be particularly efficient to do so, only that it could be done. And depending on the messaging, it could be a useful option in the dll call configuration dialog box.
    In consider
    ation of "magic",
    Kind Regards,
    Eric

    Eric,
    I'm not sure I understand exactlly what you are trying to do here.
    If you want LV to react to a dll error, why don't you just pass a return
    code that's not zero? Then, back in LV, read the return code. If it's not
    zero, create an error, and pass this to the rest of the code. The rest of
    the code is (or should, following good programming practise) has an error
    in, and the code will not execute if the input error is TRUE. It does not
    even have to be the return code, it could be any input value. The input
    values can be changed in the code, and the modified value is returnd to
    LabVIEW.
    If you want to generate an error, and put it into a buffer to be read later
    on in LV, you'll have to synchronise the code. This is the consequence for a
    construction like this, and is the same for several windows API's
    (GetLastError, etc.). the buffer will stay in memory, untill all instances
    of the dll are released from LV memory.
    BTW: A dll could create another thread. This thread can run on the
    background, like the good old TRS's in dos. (A thread like this could even
    call a LabVIEW VI that is build in a dll, just like any other api.)
    BTW: A thread created by a dll can be made to be automatically released when
    the thread is detatched, or when the process is detached. This is important,
    because LV will crash if the dll is removed from memory, but the thread is
    not stopped properly.
    Regards,
    Wiebe.
    "Eric6756" wrote in message
    news:[email protected]...
    > Greg,
    >
    > As I think I lost you in the point of this line of questions, let me
    > back up.
    >
    > A couple of week ago I asked the following question, "Is there a
    > labVIEW library call that can be made from a dll to tell labVIEW to
    > abort the calling vi thread?" To that question you made the following
    > statement:
    >
    > "... and I doubt that there is a function to do that from a DLL as the
    > DLL could be arbitrarily deep down the stack and the function called
    > would have to magically find the VI that it wants to abort. And don't
    > forget that DLLs can be called by multiple VIs at the same time."
    >
    > You seem to be saying here that what I'm asking for is not possible.
    > And having thought about this for a while, I didn't understand why
    > not.
    >
    > For the moment I'm going to ignore the caveat you just put into the
    > dll calling presumptions I've made and assume the dll is going to
    > execute synchronously within a thread. As the original question
    > suggests, the objective here is to message labVIEW from a dll to
    > provide the same functionallity as a CIN, namely return an error code
    > to labVIEW from a dll.
    >
    > A library function could do this as follows:
    >
    > First, the library function would have two modes; set error, and
    > return error
    >
    > (1) set error:
    >
    > 1.1 get the set error caller thread ID from API
    > 1.2 get the passed in error
    > 1.3 store the error and associated thread ID locally
    >
    > (2) return error
    > 2.1 get return error caller thread ID from API
    > 2.2 locate the error, if any, associated with thread ID
    > 2.3 return the error and clear it locally
    >
    > Now, if a dll encountered an error that it wanted labview to deal
    > with, it would call the error function to set the error code. When
    > the dll call returns control to labVIEW, labVIEW could call the
    > function to return the error. This of course works only if the dll
    > call is synchronous within a thread. Obviously, if the dll releases
    > the thread before it returns, then more than one dll call can be made
    > from the thread and the presumption that an error could be uniquely
    > associated with a thread is itself an error.
    >
    > Having looked at your reply again, I think though your answering a
    > different question than I asked. I just wanted a function to message
    > labVIEW to abort the vi chain, I don't want to abort a vi chain from
    > within the dll. It is a feature of CIN calls which I wanted in dll
    > calls.
    >
    > That a dll call may not be synchronous within a thread throws a wrench
    > in the works. Apparently I've just chased down a dead end.
    >
    > Hey, but thanks for the wrench...
    > Kind Regards,
    > Eric

  • Any performance overhead if we get iterator over values stored in map

    Hi Everybody,
    Is there any performance overhead if we get iterator over values stored in map. like this
    Iterator itr = rolesMap.values().iterator();
    if yes please explain...thanks in advance.

    ejp wrote:
    That's rather out of date. It is how Hashtable works, but as regards HashMap it isn't. The keySet() iterator and the values() iterator are both written in terms of the entrySet() iterator. There is no skipping over unused slots.Out of date? In that case there's been a recent advance in hashed data structures I've missed.
    Or the HashMap implementation has been recently changed to internally link entries to improve iteration performance. I doubt that because such a list would degrade the performance of the HashMap in other ways and that's unacceptable (and unnecessary because of LinkedHashMap).
    Besides, what I said is in the Java 6 API documentation to LinkedHashMap. It may be out of date but I doubt it.
    So here we are with a fact of nature: Any iteration of a hash based data structure will be proportional to capacity rather than the number of entries, unless a supportive list style data structure is introduced to overcome this.

Maybe you are looking for

  • How do I make who and finger commands show hostnames?

    Running a "who" or "finger" command does not show the hostname column on Solaris 9. The odd part is that it works on other Solaris 9 systems except one. We need to be able to know the following: 1) users currently logged in 2) pseudo terminal number

  • Kindle Fire HD support

    I picked up a Kindle Fire HD today and found that one of my apps is not working on the device I have found no documentation that indicates that there are any problems with older apps and the Kindle Fire HD, and Gold Level support has provided no help

  • Logon Errors in B2C webshop

    hello guys, This is urgent,Iam trying to logon to B2C webshop by registering as a consumer, i have given have used German address,after entering the address data when i try to save the user,i get the following error "You are not authorized to assign

  • Lenovo S410p accidentally deleted NVIDIA Driver from device manager

    Hello, I "accidentally" uninstalled my NVIDIA GeForce 720M driver from my device manager when I tried to reinstall the driver. Now it no longer shows up on the device manager at all, and I cannot install any driver since the laptop does not detect it

  • RDB BLOB problem

    Hi. I have problem writing blob into RDB database table via JDBC driver. I use setBinarySteam() or setBytes() method in PreparedStatement. If table has NOT NULL constraint on blob-field I'm trying to write JDBC driver throws exception: java.sql.SQLEx