I want a non thread-safe container

My application met with muti-threaded, it seems unwise to use a vector, which can cause the deadlock. So should what container I use?

It is fairly easy to roll your own container. But the danger of blocking with a vector is weak as it syncs on itself, but nothing else in their own country. Just do your synchronization of higher level on something else than the vector itself and all it should cost is some additional synchronization overhead.

Tags: BlackBerry Developers

Similar Questions

  • Does container managed entity manager is thread-safe in stateless session bean?

    Hello

    I have read JEE6 doc and confused with

    Manager managed entity containing does (injected by PersistenceContext annotation) is thread-safe in bean of stateless session in env mutiple-thread?

    See code below, if there are 2 requests to stateless session bean in 2 concurrent threads, is it using the same Instance of the managing body or not?

    @Stateless (name = "HRFacade", mappedName = "HR_FACES_EJB_JPA-HRFacade-HRFacade")

    / public class HRFacadeBean implements HRFacade, HRFacadeLocal {}

    @Resource

    SessionContext sessionContext;

    @PersistenceContext (unitName = "HRFacade")

    Private EntityManager em;

    public places (places sites) persistLocations {}
    EM. Persist (rentals);
    return places;
    }

    public places (places sites) mergeLocations {}
    Return em.merge (rentals);
    }

    {} public void removeLocations (places sites)
    location = em.find (Locations.class, locations.getLocationId ());
    EM. Remove (rentals);
    }

    / * < code > o selection of the places where < code > * /.
    @TransactionAttribute (TransactionAttributeType.NOT_SUPPORTED)
    public list < location > getLocationsFindAll() {}
    Return em.createNamedQuery ("Locations.findAll", Locations.class) .getResultList ();
    }

    }

    Yes its safe. Stateless beans would be useless if it wasn't the case. That's the bit of "controlled container" description, as long as you leave the container do its job, you don't have to worry about such details.

  • tables dynamic thread-safe

    Hi all

    trying to convert my application single-threaded for multithreading, that I met a new obstacle:

    I would like to have a global data structure. This structure must be dynamically allocated and reallocated as the number of threads (and thus the size of the structure) depends on the program execute / user.

    The main thread as long as secondary threads should be able to access this structure, so I need to use a variable in thread safe, somehow. All the samples I've traveled so far, either use a single variable using the DefineThreadSafeScalarVar macro, or an array of size fixed by using the DefineThreadSafeArrayVar macro.

    I haven't found an example of this type of a dynamic array, unfortunately... Some kind soul would be willing to teach me how to proceed?

    Thank you

    Wolfgang

    In your case, you must use a TSV scalar that contains the pointer is allocated/re-allocated. See the following example of a TSV that mimics a dynamic array of integers. In some cases, a better solution would be to have a TSV scalar that contains a list, say, box tools ListType.

    #include

    DefineThreadSafeVar (int *, DynMem);

    void main (void)
    {
    int * pDynMem, i.;
       
    Initialize the TSV
    InitializeDynMem();
       
    Define HSV 'table' to hold 10 integers
    SetDynMem (malloc (10 * sizeof (int)));
       
    Set and get the 'elements' of TSV
    pDynMem = GetPointerToDynMem();
    for (i = 0; i< 10;="">
    {
    (* pDynMem) [i] = i;
    printf ("DynMem [%d] = %d\n", (* pDynMem) [i], i);
    }
    ReleasePointerToDynMem();
       
    Resize the TSV "array".
    pDynMem = GetPointerToDynMem();
    * pDynMem = realloc (* pDynMem, 20 * sizeof;)
    for (i = 10; I)< 20;="">
    (* pDynMem) [i] = i;
    for (i = 0; i< 20;="">
    printf ("DynMem [%d] = %d\n", (* pDynMem) [i], i);
    ReleasePointerToDynMem();
       
    Free TSV "array".
    pDynMem = GetPointerToDynMem();
    Free(*pDynMem);
    ReleasePointerToDynMem();
       
    Cancel initialization of TSV
    UninitializeDynMem();
    }

  • Is JTextArea append() method thread-safe?

    It was noted in another ad that in JDK 7, the JTextArea append() method is more explicitly described as being thread-safe:

    http://download.Java.NET/jdk7/docs/API/javax/swing/JTextArea.html#append
    I do not use JDK7, but here is the code for the method append in JDK6_7 (I guess that he has not changed in JDK7?):
    public void append(String str) {
        Document doc = getDocument();
        if (doc != null) {
            try {
                doc.insertString(doc.getLength(), str, null);
            }
            catch (BadLocationException e) {
            }
        }
    }
    As you can see the code simply calls the insertString (...) method of the Document. JDK7 documentation, the insertString (...) method is still marked as being thread-safe:

    http://download.Java.NET/jdk7/docs/API/javax/swing/text/PlainDocument.html#insertString

    I always confused when you work with Threads. A few questions:

    (1) if the append() method eventually calls insertString (...), which is a safe method of thread that does the method append() safe thread?

    (2) assuming that the code in the method append has not changed in JDK 7 documentation has been bad for the first 6 versions of the JDK? Or is the documentation for JDK 7 lack instruction thread safe?

    (3) I know in the past I've suggested append() is thread-safe. It seems I should change my advice to wrap this method in a SwingUtilities.invokeLater (...). Is this a safe approach in any case to avoid confusion?

    camickr wrote:
    The PlainDocument does not use a lock. Here's the code for the JDK6:

    The lock is #insertString AbstractDocument. The additional filter of PlainDocument #insertString code is thread-safe, because it uses only local variables and GetFilter() reading is true or false/null.

    Even if filtering is not done, is it not theoretically possible that change of threads can occur before the super.insertString (...) is running?

    I guess what I'm asking is that if a single line of code runs before the writeLock() method is called is there way for there to be threading issues?

    Yes, but it's similar to the way in which a synchronized map is thread-safe, you can call containsKey (k) followed by get (k), and these methods are "thread-safe", but if you want to combine you need to do an extra lock. The only thread safe object is immutable.
    One difference here is that a card will return NULL but AbstractDocument launches a BadLocationException. Also if you want to get the lock, the only option is to subclass since writeLock() is protected and final.

  • Updated the last updated Aug.5 2016 and be over three quarter turn, I want to start in safe mode, all responses.

    Update will not finish, want to start in safe mode, please help.  It's updated Aug.5 2016.

    Start in Safe Mode. What do you expect to make? You must do this:

    Reinstall El Capitan without erasing the drive

    Please make sure that you back up.

    1. Restart the computer. Immediately after that the chime hold down the command and R until the Utility Menu appears.
    2. Select disk utility, then click on the continue button.
    3. Select the withdrawal (usually Macintosh HD) entry of the volume of the list to one side.
    4. Click first aid icon in the toolbar. Wait until the button is active, then click it.
    5. Quit disk utility and re-enter the Utility Menu.
    6. Select Reinstall OS X and click on the continue button.

    Also, see this tip for user: basic steps for the OS X upgrade.

  • Are thread-safe queues

    Hi all

    Are secure i.e. thread queues are enqueue, dequeue Atomic etc?

    I'm looking to use queues to transfer objects between concurrent loops States, but am worried if I need to protect the access via a semaphore.

    Thank you

    Phill

    Yes.  Queue operations are atomic.  It is safe to assume that everything in LabVIEW is thread-safe, unless otherwise stated, it is since always a language designed for operation in parallel.

  • Thread Safe variables - several symbol at link definitions

    I'm going through the tutorial "Multithreading in LabWindows/CVI.

    The following line is in the tutorial about the variables in Thread-Safe:

    "If you need to access the variable in thread-safe from more than one file source, use the macro DeclareThreadSafeScalarVar or DeclareThreadSafeArrayVar in an include (.h) file for create statements for the accessor functions."

    OK works with a source file, but when I include the header file in a second file from the source, I have "Several definitions for symbol" errors when link for all functions of accessor in the two source files.

    It's probably something simple, but after a few hours I'm at a loss. Any ideas are appreciated.

    Scott T

    You should have DefineThreadSafeXXX in exactly a source file and a DeclareThreadSafeXXX in any number of source files (or in a file header included in the source files). The following works for me in 2012 of the CVI:

    / * temp.h * /.

    #include

    DeclareThreadSafeScalarVar (double, Num);

    void test (void);

    * Temp.c * /.

    #include "temp.h".

    DefineThreadSafeScalarVar (double, Num,-1);

    void main (void) {}

    InitializeNum();

    test();

    }

    / * temp2.c * /.

    #include "temp.h".

    void test (void) {}

    SetNum (1.0);

    }

  • BBM SDK Thread Safe?

    Anyone know if the messages sent/received are thread-safe, or do we do us our own synchronization to ensure that a new message does not come before the end of the old?

    In this case messages would be delivered in the order they are received.  Each call is on the same thread.

  • OTMQ + JCA - it is thread-safe?

    Hello

    Currently, we are conducting a doubt in our minds regarding using the OTMQ with a JCA component. We build into our architecture a component in order to call by a java bean that is deployed inside a WL server, an OTMQ instance that is running on the same machine. This OTMQ instance is the platform independent (not Tuxedo + OTMQ) OTMQ and on the side of Java, we would use a mixture of JCA and, if necessary, JNI calls to establish a connection between these two components.

    My question here is, because WL will have multiple instances of this bean, are there problems I should be aware with respect, using multiple threads in such a component? In my view, that should we not we have no problem with that, given that OTMQ works similar like Tuxedo/q, but I was wondering if there is something you miss here.

    If you could just help me understand if I am having trouble with this architecture, I would be very grateful.

    Thank you

    brunno Attorre

    Hi Brunno,

    The JCA adapter is thread-safe, and if you find any problems associated with the JCA adapter threads, report it to the Support of Oracle.  About OTMQ, in my opinion, that these libraries are thread-safe, you can create an OTMQ multi-threaded server, but we do not support the use of JNI to call one of our libraries.  Why would you use JNI?  You can simply use the JCA/waiting for Message Queuing adapter.

    Kind regards

    Todd little

    Chief Architect of Oracle Tuxedo

  • is NamedCache thread-safe?

    Hello

    I use coherance NamedCache (say "TradeCache"), to store objects in the cache.

    My application is designed so that multiple threads can place data in "TradeCache" at the same time.

    What kind of thread safety, we need to take care of?

    Hi user 1696.

    With regard to your questions:

    (a) what kind of locking is used, is that they lock the entire map?
    (b) or basic locking key is made?

    Coherence use essential basic locking.

    (c) if by default all implementations are thread-safe, which is the use of namedcache.lock () api

    NamedCache.lock () is provided so that applications that make use of coherence can have some control over several readers and/or authors using the same object in space of the application. This is not to prevent corruption in the cache store. It must provide a way for applications to control the race as conditions have several operations on the same object at the same time. So that the application can control which of the puts should occur for example.

    Can you please me to any document (short & concise) cohernace good.

    You can find pointers to official documentation and white papers, among others to the OTN on Oracle coherence page following

    http://www.Oracle.com/technology/products/coherence/coherence_suite.html

    and there is also a wealth of information on the site of the Oracle coherence Knowledge Base at:

    http://coherence.Oracle.com

    In regards to your 2nd question about 2 java clients using the same NamedCache and do put and remove operations, you can provide more details on your example? Java clients 2 performing put or remove on the same object or different objects?

    Patrick

    Published by: P Fry on April 30, 2010 12:09

  • SimpleParser consistency class is not thread-safe?

    Coherense has the utility class to XML very convinent which we use it a lot in our coherence-related applications.

    But meet us some lock mysterious question (dead end, maybe?) and have identified that it would be that the com.tangosol.run.xml.SimpleParser class is not thread-safe.

    We use tomcat 6 and Spring 2.0.6.

    Application Web has 2 bean that implements the InitializingBean interface.

    Bean A afterPropertiesSet() method will use com.tangosol.run.xml.XmlHelper.loadXml method to parse a XML file.
    Method of Bean B afterPropertiesSet() will acts as a tcp expand clients and retrieve data from a cluster of coherence. Which, I think, consistency will also use XML class useful during parsing of the configuration files.

    We meet randomly blocking of tomcat (which never end starting webapp deployment alternation) as 1 on 2 or 3 tests.

    Use of jconsole and tomcat connection we can see that the main thread stuck in the class SimpleParser. Here's the thread dump.

    Name: main
    State: EXECUTABLE
    Blocked in total: 156 Total expected: 0

    *************************************************************************************************

    Stack trace:
    com.tangosol.run.xml.SimpleParser.instantiateDocument(SimpleParser.java:150)
    com.tangosol.run.xml.SimpleParser.parseXml(SimpleParser.java:115)
    -locking com.tangosol.run.xml.SimpleParser@f10c77
    com.tangosol.run.xml.SimpleParser.parseXml(SimpleParser.java:71)
    com.tangosol.run.xml.SimpleParser.parseXml(SimpleParser.java:84)
    com.tangosol.run.xml.XmlHelper.loadXml(XmlHelper.java:109)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
    org.springframework.beans.factory.support.AbstractBeanFactory$ 1.getObject(AbstractBeanFactory.java:251)
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
    -locking java.util.concurrent.ConcurrentHashMap@dee55c
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
    -locking java.lang.Object@d21555
    org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
    org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
    org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
    org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
    org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
    -locking org.apache.catalina.core.StandardContext@1c64ed8
    org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    -locking java.util.HashMap@76a6d9
    org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:825)
    org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:714)
    org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
    org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
    org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    -locking org.apache.catalina.core.StandardHost@1c42c4b
    org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    -locking org.apache.catalina.core.StandardHost@1c42c4b
    org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    -locking org.apache.catalina.core.StandardEngine@37fd24
    org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    org.apache.catalina.core.StandardService.start(StandardService.java:516)
    -locking org.apache.catalina.core.StandardEngine@37fd24
    org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    -locked [Lorg.apache.catalina.Service;@1cc55fb
    org.apache.catalina.startup.Catalina.start(Catalina.java:566)
    sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke (unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke (unknown Source)
    java.lang.reflect.Method.invoke (unknown Source)
    org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    org.apache.catalina.startup.Bootstrap.main (Bootstrap.java:413)

    *************************************************************************************************

    After we have add the tag is based on applying bean B wait on A bean to complete initialization, we encounter is no longer blocked when starting tomcat.

    We suspect that maybe SimpleParser class is not thread-safe and will cause potential deadlock issue.

    Published by: user639604 on June 22, 2009 10:36

    It seems that the 'hand' thread comes to the point that he is responsible for the class of SimpleDocument around the same time as the thread "Timer-0"comes to the point where he is in charge of the class ExternalizableHelper. According to what son get on-demand, if the loading of the class ExternalizableHelper happens point of needing to SimpleDocument after the main thread starts to load SimpleDocument, then a deadlock (inside the JVM loading infrastructure class) happen.

    While you are correct that it is our fault (we shouldn't have used a subset of the ExternalizableHelper static initializer), there is probably a simple solution; Just do the following in an initializer static for your first loads or the classes related to the coherence, for example ClusterConfigurator and OPCacheManager:

    static
      {
      // this should force the ExternalizableHelper class to be loaded
      ExternalizableHelper.makeTrint(0L);
      }
    

    Peace,

    Cameron Purdy | The Oracle coherence

  • Complete a teststand thread safe

    Hello

    I created a vi using the audio wizard and vibrations. He simpply plays a tone of 1 kHz. I start it to use a new thread execution in TestStand (generate the audio wire)

    I then proceed to route the audio from my USE speaker R - the operator must then select the pass/fail if hear sound out of the speaker.

    Then, I continue to send the sound to the speaker L and provide a pass/fail another popup.

    I wonder how I can kill the audio thread 'generate' without including a timeout routine in my vi?

    Not sure if this is possible or safe?

    Thanks & best regards,

    Shane.

    Hey Don1,.

    It seems that this could be an easy fix if I understand your problem. The idea is to have the operator, click go, and then a tone is played on the right side, they confirm / deny hearing it and then it moves on the left side and confirm or deny. The best way to take care of this would be to use only one step for each audio side, for a total if you want, but the idea is to have the LabVIEW to hold the popup of user until the user interacts with it. This could be accomplished with separate vi have by a dialog box pop-up in a while loop when the right audio is running, once the user confirms audio, it stops the loop and returns the result to TestStand. They can then move to the left audio in the same way. If you prefer this in one step, you could use consecutive while loops to hold the user up to the interaction operator dialog box and then move on to the next audio side and then pass the results back as needed.

    Thanks again,

    Nick

  • In windows 7 - I want to find all files containing "a word or phrase in the file". The standard search XP box.

    In Windows 7 - I want to search/find all files containing "a word or phrase in the file".  The search box on the old standard XP.

    I do NOT provide: name of file. file type; drive letter; etc - nothing.

    I tried to search for this - just can't find any discussion.  And of course, do not have this research would be crazy. That's precisely what we have a computer for.

    And no 3rd party program is allowed.

    There is an option that seems to match what you are looking for:

    If it was useful, you can vote by clicking on the green triangle. If it solves the problem, click on propose as answer. Thank you!

  • Non Web-safe fonts appear low resolution preview mode and in the browser

    I have a problem when you use fonts that are not safe, no matter which sometimes I use it displays low resolution and looks awful in preview mode, ex in the web browser. I understand that the fonts that are not supported are converted to images instad of the text but why do these low resolution? The use of the browser has an effect on how it appears? I am currently using safari.

    This is how the text appears: (future is a non-secure web and Arial and Helvetica are web safe)

    In Adobe Muse:

    moeAhsQ.png

    In preview mode:

    GgR0Wfd.png

    Post edited by: Abhishek Maurya - updated the URL of the broken image

    Hi Johan,.

    While exporting the images in photoshop, try to add the transparency of 1% and save them as png Muse to avoid compressing the images. Let me know if that makes a difference.

    - Abhishek Maurya

  • Divide two text frames linked in 2 images to separate the non threaded text

    I have more trouble with this.  CS4.

    What I am wanting to do is separate from the two sections, if it's the same answer.  I want that my stand-alone sections, not threaded. Thank you!!!

    In your scripts Panel, you will find one under Application > samples called Frame break.  Select the image, then click on that.  Fact!

Maybe you are looking for