Java Thread allow lock on variable?

I have a situation where i have more then 20 threads each has some variable call it- int [ ] variable.
Now each thread wants to see this variable of all other thread and any thread is allowed to add value of int array of any other thread.
Now suppose a reference to int array or all threads is availabe to all other threads, is there a way to put a lock on it?
So say Thread 1 is changing int array of Thread 2. Can thread 1 put a lock on thread 2's int array so while it is changing the value of that int array no one else can do anything to it?
At the same time if some other thread is accessing the int array of thread 2, thread1 is put on hold until it gets it's turn to put lock on it?
Thx!!!

Now suppose a reference to int array or all threads
is availabe to all other threads, is there a way to
put a lock on it? Look at the "synchronized" keyword.
So say Thread 1 is changing int array of Thread 2.Typically variables aren't associated with threads but rather with other objects.
You can have thread local variables, but the point of that is to preclude this kind of thing.
Read this:
http://java.sun.com/docs/books/tutorial/essential/concurrency/

Similar Messages

  • Question about java thread implementation

    Hi All,
    I am comparing the performance of the Dining philosopher's problem
    implemented in Java, Ada, C/Pthread, and the experimental language I
    have been working on.
    The algorithm is very simple: let a butler to restrict entry to the
    eating table, so that deadlock is prevented.
    It turns out that the java code is the winner and it is 2 times faster than C!
    The comparison result really surprised me, and raised a big
    question mark : why java runs so fast? I did not use high-level synchronization
    constructs like Semaphores, atomic variables, etc.
    I vaguely recall that Java thread is actually implemented by the underlying
    system thread library(so on linux, the default would be NPTL, on windows NT threads,
    and on Mac OSX it would be Cthread?). Can no longer remember where I read that.
    Does anyone here have some notions about the Java thread
    implementations(where is this formally explained)? or Does anyone know where
    I can possibly find relevant literature or the answer?
    thanks a lot.
    cheers,
    Tony

    Peter__Lawrey wrote:
    google has lots of information on java threaded.
    One thing java does is support biased locking. i.e. the thread which last locked an object can lock that object again faster.
    This may explain the difference. [http://www.google.co.uk/search?q=java+usebiasedlocking]
    Note: you can turn this option off and other locking options to see if a feature is giving you the performance advantage.
    Personally I have found that real world multi-threaded applications are easier to write in Java, esp. when you have a team of developers. For this reason, alot of C/C++ libraries are single threaded, even when there would be a performance advantage in being multi-threaded (because its just too hard in reality to make it thread safe and faster because of it)I didn't know that, very interesting :-)

  • Second posting - spent hours on this - yesterday and today - I have downloaded the FlashPlayer upgrade (now 10 times), in Security - no pop-ups are checked, the "allow Java" and "allow other other plug-ins" are both checked.  I have re-booted after the Fl

    Repeat message - I have downloaded the FlashPlayer upgrade (now 10 times), in Security - no pop-ups are checked, the "allow Java" and "allow other other plug-ins" are both checked.  I have re-booted after the Flash-Player upgrades - still "pop=ups blocked"

    Hello,
    Please provide the following information:
    Your operating system & version
    Your web browser(s) & version
    Your Flash Player version
    Explain your problem in step-by-step detail if possible
    A direct link to a page that demonstrates the problem
    If you get error messages, please quote them exactly, or provide a screenshot: http://forums.adobe.com/thread/1070933
    Thank you.
    Maria

  • Get Max no of Threads allowed by OS

    Is there a way in java to programatically get the maximum number of threads that are allowed to be created by an operating system?
    Thru my readings on forums, I gather that though there is no such limit for green-type of java threads (I am not sure what green-type means), other regular threads are bound by the max thread limit allowed by the kernel. Is there a way to programmtically get this limit?
    If there is no such API to get this information in Java directly, is there some command that can be invoked using the Runtim.exec() methods depending upon the OS type?
    Thank you

    It depends probably on the OS, the mem size, the number and type of CPUs... in short: Java isn't really supposed to care.
    There is no way, and IMO there also isn't really a need to know.

  • Are static methods in Java thread safe?

    Are static methods in Java thread safe?
    thanks,
    suresh

    if static method use the instance variable
    You mean member variable, where member variables are either class variables (static) or instance variables (non-static).
    then you have to make it thread safe using
    synchronization Not necessarily. Depends on requirements and usage context.
    else in case of local var. it
    is thread safe. Not necessarily. That local variable could refer to an object that's visible to multiple threads.
    Statements like "Local variables are threadsafe but member variables aren't" are an oversimplification.
    Something is threadsafe if it cannot be made to behave incorrectly simply by running it in a multithreaded context. Determining that can be very difficult.

  • Java Thread run some day then death ,use jstack check it,it  run again, is

    hi all;
    I write a java program run as linux daemon,
    command line is >nohup java myclass &>/dev/null
    it run some day ,then death, ,look like death lock ,but thread not exit
    if i use jstack checke it ,it run again!
    my env is
    Linux version 2.4.20 ,redhat linux
    jstack 14616
    Attaching to process ID 14616, please wait...
    Debugger attached successfully.
    Client compiler detected.
    JVM version is 1.5.0_02-b09
    my program like
    commandline nohuo java StartUp >/dev/null &
    public Class StartUp{
    public static void main(String[] argv){
       Connection con = getDBConnection
         Thread t1 = new Thread(new MyRun(con));
      t1.start();
         Thread t2 = new Thread(new MyRun(con));
      t2.start();
      for(;;){
      Thread.sleep(100);
    public class MyRun implements Runnable{
    Connection con;
    public MyRun(Connection c){con = c;}
    public void run(){
         for(;;){
         object = readData(con);
         process(object);
         log.info("watch info ....");
         Thread.sleep(500);
    }

    Today i found my program hang, i use kill -SIGQUIT to print thead trace
    but i can't find the bug,after send singal ,the thread run again!
    another question
    how to detect a thread is hang?and use another thread restart it?
    thread dump
    Full thread dump Java HotSpot(TM) Client VM (1.5.0_02-b09 mixed mode, sharing):
    "pool-1-thread-2" prio=1 tid=0x08447858 nid=0x5aa6 waiting on condition [0x4680f000..0x4681021c]
    at sun.misc.Unsafe.park(Native Method)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:118)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1772)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:470)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:674)
    at java.lang.Thread.run(Thread.java:595)
    "pool-1-thread-1" prio=1 tid=0x08392740 nid=0x5aa5 waiting on condition [0x4678f000..0x4678ff1c]
    at sun.misc.Unsafe.park(Native Method)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:118)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1772)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
    at com.ejet.mms.MmsSend.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
    at java.lang.Thread.run(Thread.java:595)
    "Low Memory Detector" daemon prio=1 tid=0x080a18b0 nid=0x5a9f runnable [0x00000000..0x00000000]
    "CompilerThread0" daemon prio=1 tid=0x080a0360 nid=0x5a9e waiting on condition [0x00000000..0x417e2c04]
    "Signal Dispatcher" daemon prio=1 tid=0x0809f478 nid=0x5a9d waiting on condition [0x00000000..0x00000000]
    "Finalizer" daemon prio=1 tid=0x080989e8 nid=0x5a9c in Object.wait() [0x413e4000..0x413e441c]
    at java.lang.Object.wait(Native Method)
    - waiting on <0x66c18420> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
    - locked <0x66c18420> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
    "Reference Handler" daemon prio=1 tid=0x08097cf8 nid=0x5a9b in Object.wait() [0x41364000..0x4136451c]
    at java.lang.Object.wait(Native Method)
    - waiting on <0x66c184a0> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:474)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
    - locked <0x66c184a0> (a java.lang.ref.Reference$Lock)
    "main" prio=1 tid=0x0805ae68 nid=0x5a98 waiting on condition [0xbfffc000..0xbfffc4f8]
    at java.lang.Thread.sleep(Native Method)
    at com.ejet.mms.MmsStartup.main(Unknown Source)
    "VM Thread" prio=1 tid=0x08095218 nid=0x5a9a runnable
    "VM Periodic Task Thread" prio=1 tid=0x080a2d40 nid=0x5aa0 waiting on condition

  • Java.lang.IllegalStateException: Locked entries

    Hi,
    My colleagues create an ADF application which is migrated from Jde 11.1.1.1. After migeration, they use Jdev11.1.1.2 to modify this application.
    They have a button. After the button is clicked, an exception appears and the page goes to the error page.
    They have to back to the original page from web browser.
    Caused by: java.lang.IllegalStateException: Locked entries
    [Thread[[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads]->]
         at fuego.pool.TimedMultiValuatedCache.clear(TimedMultiValuatedCache.java:384)
         at fuego.connector.impl.pool.PoolManager.stop(PoolManager.java:71)
         at fuego.connector.impl.BaseJDBCConnector.stop(BaseJDBCConnector.java:296)
         at fuego.connector.ConnectorService.stopService(ConnectorService.java:778)
         at fuego.connector.ConnectorService.stop(ConnectorService.java:486)
         at fuego.connector.CompositeConnectorService.restartDirectoryConnectorService(CompositeConnectorService.java:54)
         at fuego.directory.DirectoryConfigurationManager.loadDirectoryConfiguration(DirectoryConfigurationManager.java:395)
         at fuego.directory.DirectoryConfigurationManager.getDirectoryConfiguration(DirectoryConfigurationManager.java:331)
         at fuego.directory.DirectoryConfigurationManager.getDirectoryConfigType(DirectoryConfigurationManager.java:313)
         at fuego.directory.provider.Factory.getDirectoryFactory(Factory.java:216)
         at fuego.directory.Directory.fillPassport(Directory.java:123)
         at fuego.directory.DirectoryPassport.fillPassport(DirectoryPassport.java:275)
    ####<2009-12-22 CST> <Error> <org.apache.beehive.netui.pageflow.internal.AdapterManager> <WINDOWS-D6GMTZ2> <AdminServer>
    <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1261469009637> <BEA-000000> <ServletContainerAdapter manager not initialized correctly.>
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused By: weblogic.common.ResourceException: weblogic.common.ResourceException: Could not create pool connection. The DBMS driver exception was: The Network Adapter could not establish the connection
         at weblogic.jdbc.common.internal.ConnectionEnvFactory.createResource(ConnectionEnvFactory.java:256)
    ####<2009-12-22 CST> <Error> <org.apache.beehive.netui.pageflow.internal.AdapterManager> <WINDOWS-D6GMTZ2> <AdminServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1261473870326> <BEA-000000> <ServletContainerAdapter manager not initialized correctly.>
    Caused By: weblogic.common.ResourceException: weblogic.common.ResourceException: Could not create pool connection. The DBMS driver exception was: The Network Adapter could not establish the connection
    ###<2009-12-22 下午05时24分25秒 CST> <Error> <Deployer> <WINDOWS-D6GMTZ2> <AdminServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1261473865443> <BEA-149205> <Failed to initialize the application 'ysjk109' due to error weblogic.application.ModuleException: .
    -----------------------------------

    Hi,
    I paste this thread in Weblogic forum. However, I have not get any solution.
    The ADF application is created by developers. Then, it is deployed to a Weblogic (10.3.2) domain.
    Testers start to testing functions. Every tester has a username to login the deployed adf application. Each username is unique. The above exception only appears in the deployed application during testing.
    Developers have their own usernames and each username is unique and different from usernames of testers.
    Developers run this application in the weblogic installed with jdeveloper on their machines and this exception has not appear.

  • Problems with java Thread

    I'm reading book "JAVA THREAD" published by OREILLY.
    And on fifth chapter, it gives an example.
    one Thread's two method:
    private boolean done = false;
    public void run()
    while(!done)
    foo();
    public void setDone()
    done = true;
    it says, the run method will be compiled as machine code:
    Begin method run
    load register r1 with memory location 0xff12345
    Label L1:
    Test if register r1 == 1
    If true branch to L2
    Call method foo
    Branch to L1
    Label L2:
    End method run
    setDone method will be compiled like:
    Begin method setDone
    Store 1 into memory location 0xff12345
    End method setDone
    And it says " because Run method will never reload 0xff12345 to register r1(in while loop), so setDone method will never lead to run stop.
    I'm so puzzled with this. I have test this code on windows platform, run method can stop after another Thread call setDone method !.
    but I think "JAVA THREAD" should have error on this, so why ?

    If the book says it will happen like that, then the book is wrong.
    I think what they meant--and what would be correct to say--is that that is an example of what could happen if you don't synchronize all access to the run variable.
    The point is this: Threads can have local copies of variables, that are separate from other threads' local copies and separate from the "master" copy. The spec doesn't define where those local copies live--the implementation can put them anywhere it wants--but the most natural and sensible thing would be to store the local copies in CPU registers, rather than in main mem.
    The example the book gave shows what might happen if that VM stores threads' local copies in registers. There's no guarantee that the problem they described will happen, but it could, so you have to guard against it.
    You guard against it by declaring that shared variable volatile, which requires that the threads use the master copy rather than their local copies, or by synchronizing every access to that thread. Syncing requires reading from the master copy on entering the sync block (or on first access) and writing out to the master copy upon leaving the sync block.

  • How to 'STOP' a running java thread in J2ME?

    Dear All,
    How to 'STOP' a running java thread in J2ME?
    In the middleware viewpoint, for some reasons we have to stopped/destroyed the running threads (we have no information how these applications designed).
    But in J2ME, Thread.destroy() is not implemented. Are there other approaches to solve this problem?
    Thanks in advance!
    Jason

    Hi jason,
    Actually there are no methods like stop() and interrupt() to stop the threads in J2ME which is present in normally J2SE Environment.
    But the interrupt method is introduced in Version 1.1 of the CLDC.
    So, we can handle the thread in two ways.
    a) If it is of single thread, then we can use a boolean variable in the run method to hadle it. so when the particular boolean value is changed , it will come out of the thread.
    for eg:
    public class exampleThread implements Runnable
    public boolean exit = false;
    public void run()
    while(!exit)
    #perform task(coding whatever u needed)
    public void exit()
    exit = true;
    b) If it is of many threads then we can handle using the instance of the current thread using currentThread() method
    for eg:
    public class exampleThread implements Runnable
    public Thread latest = null;
    public Thread restart()
    latest = new Thread(this);
    latest.start();
    public void run()
    Thread thisThread = Thread.currentThread();
    while( latest == thisThread )
    #perform some tasks(coding part);
    public voi d stopAll()
    latest = null;
    while ( latest == thisThread )
    performOperation1();
    if( latest != thisThread )
    break;
    performOperation2();
    Regards,
    Prathesh Santh.

  • Why did the thread get locked or deleted?

    Disclaimer: Apple does not necessarily endorse any suggestions, solutions, or third-party software products that may be mentioned in the topic below. Apple encourages you to first seek a solution at Apple Support. The following links are provided as is, with no guarantee of the effectiveness or reliability of the information. Apple does not guarantee that these links will be maintained or functional at any given time. Use the information below at your own discretion.
    Occasionally you may see a thread get locked or deleted, or the possibility of a user having been banned. This tip is a viewpoint of an end user of how the Terms of Use apply to deletions, locks, or bans. Moderators may at their discretion choose these actions as the Terms of Use allow them to, even when none of these points below matter.
    When you signed up on this board, a Terms of Use page was agreed to in order for you to enter. That Terms of Use page is also on the link "Help & Terms of Use" on the right hand side. Posts themselves may get deleted that weren't the source of the thread being locked or deleted. So if you didn't disobey the Terms of use, someone else might have.
    Do not take either as a sign of censorship, a sign of personal chastisement, or anything negative per say. This is after all a community open to the public.
    When one of the terms of use is violated, it is either because it does not offer constructive points of view for fixing a technical issue from end user to end user, or it is overly digressive from doing such actions. Terms of use suggest to avoid:
    1. Prognosticating.
    2. Guessing Apple's policy.
    3. Offer advice on something which may be against copyright laws.
    4. Offer advice on something which would violate a license agreement.
    5. Posting in a thread with "me toos". Try to solve the problem at hand. It makes it very hard for those of us trying to help the original poster when additional people chime in, saying they too have the same problem, or have a problem almost identical. Those trying to help
    the original poster, may not know if the solution applies to all the people having the problem, or just some. It ends up requiring people coming to help to directly address a person to avoid confusing who should follow various advice.
    A Post New Topic is available at all Forum levels, but at the Category level of Discussions. For more on this discussion, see the tip here:
    http://discussions.apple.com/ann.jspa?annID=650
    6. Other things which may be illegal in the State of California or in the United States of America
    should not be suggested or inferred by what you post.
    7. Rants or complaints about people and companies.
    They are unhelpful, and really don't solve technical issues.
    Approach complaints with tact when posting in a public forum that is moderated such as this one.
    It is one thing to say, I hate this feature being missing, is there any way to get this feature added, or are there any ways of getting it from another source?
    It is another thing to blame Apple for a feature that is missing, and drop the ball at that waiting for a response. These type of posts are more likely to be frowned upon.
    Complaining of a service not rendered is also often frowned upon. There are points of contact later in this tip to address such service issues. This is a forum for addressing technical inquiries about how things work or if things can be made to work on your system.
    8. Polls asking for a feature to be added/removed are generally frowned upon, as well as polls about various apparent defects and their propensity. You are only addressing less than 1% of the Apple using population here.
    Such polls would not be very scientific even if they are carried out for long periods of time. Long threads may appear to act as polls, and may violate terms of use. If you see such a thread and wonder why it hasn't been locked or deleted, you are welcome to ask that in Discussions Feedback, or click on "Report This Post" at the bottom right corner if available.
    As the Terms of Use state, in the end essentially it is up to the moderator to decide if a thread is worthy being deleted or locked. Don't take it personally if it is. Also Level 2 through Level 5 users, while we can ask the moderators look at a thread, we are not Apple Employees. You may also ask a moderator look at a thread or an individual on the Discussion Feedback forum or by clicking Report this post at the bottom right hand corner of a specific post.
    If the purpose of your thread is to provide feedback to Apple for a product, see these pages:
    http://www.apple.com/contact/
    http://www.apple.com/feedback/
    http://www.apple.com/contact/feedback.html
    If you have isolated a bug with a procedure worthy of a software developer, sign up for a free developer account on http://developer.apple.com/ and report the bug here:
    http://bugreporter.apple.com/
    As this is a user to user forum answers may not come right away. Have patience, and usually someone eventually can come up with an answer. Some forums may not fit the subject line of your topic, and you are welcome to ask if you are unsure where to post a topic.
    This is the 2nd version of this tip. It was submitted on September 28, 2010 by a brody.
    Do you want to provide feedback on this User Contributed Tip or contribute your own? If you have achieved Level 2 status, visit the User Tips Library Contributions forum for more information.

    Disclaimer: Apple does not necessarily endorse any suggestions, solutions, or third-party software products that may be mentioned in the topic below. Apple encourages you to first seek a solution at Apple Support. The following links are provided as is, with no guarantee of the effectiveness or reliability of the information. Apple does not guarantee that these links will be maintained or functional at any given time. Use the information below at your own discretion.
    Occasionally you may see a thread get locked or deleted, or the possibility of a user having been banned. This tip is a viewpoint of an end user of how the Terms of Use apply to deletions, locks, or bans. Moderators may at their discretion choose these actions as the Terms of Use allow them to, even when none of these points below matter.
    When you signed up on this board, a Terms of Use page was agreed to in order for you to enter. That Terms of Use page is also on the link "Help & Terms of Use" on the right hand side. Posts themselves may get deleted that weren't the source of the thread being locked or deleted. So if you didn't disobey the Terms of use, someone else might have.
    Do not take either as a sign of censorship, a sign of personal chastisement, or anything negative per say. This is after all a community open to the public.
    When one of the terms of use is violated, it is either because it does not offer constructive points of view for fixing a technical issue from end user to end user, or it is overly digressive from doing such actions. Terms of use suggest to avoid:
    1. Prognosticating.
    2. Guessing Apple's policy.
    3. Offer advice on something which may be against copyright laws.
    4. Offer advice on something which would violate a license agreement.
    5. Posting in a thread with "me toos". Try to solve the problem at hand. It makes it very hard for those of us trying to help the original poster when additional people chime in, saying they too have the same problem, or have a problem almost identical. Those trying to help
    the original poster, may not know if the solution applies to all the people having the problem, or just some. It ends up requiring people coming to help to directly address a person to avoid confusing who should follow various advice.
    A Post New Topic is available at all Forum levels, but at the Category level of Discussions. For more on this discussion, see the tip here:
    http://discussions.apple.com/ann.jspa?annID=650
    6. Other things which may be illegal in the State of California or in the United States of America
    should not be suggested or inferred by what you post.
    7. Rants or complaints about people and companies.
    They are unhelpful, and really don't solve technical issues.
    Approach complaints with tact when posting in a public forum that is moderated such as this one.
    It is one thing to say, I hate this feature being missing, is there any way to get this feature added, or are there any ways of getting it from another source?
    It is another thing to blame Apple for a feature that is missing, and drop the ball at that waiting for a response. These type of posts are more likely to be frowned upon.
    Complaining of a service not rendered is also often frowned upon. There are points of contact later in this tip to address such service issues. This is a forum for addressing technical inquiries about how things work or if things can be made to work on your system.
    8. Polls asking for a feature to be added/removed are generally frowned upon, as well as polls about various apparent defects and their propensity. You are only addressing less than 1% of the Apple using population here.
    Such polls would not be very scientific even if they are carried out for long periods of time. Long threads may appear to act as polls, and may violate terms of use. If you see such a thread and wonder why it hasn't been locked or deleted, you are welcome to ask that in Discussions Feedback, or click on "Report This Post" at the bottom right corner if available.
    As the Terms of Use state, in the end essentially it is up to the moderator to decide if a thread is worthy being deleted or locked. Don't take it personally if it is. Also Level 2 through Level 5 users, while we can ask the moderators look at a thread, we are not Apple Employees. You may also ask a moderator look at a thread or an individual on the Discussion Feedback forum or by clicking Report this post at the bottom right hand corner of a specific post.
    If the purpose of your thread is to provide feedback to Apple for a product, see these pages:
    http://www.apple.com/contact/
    http://www.apple.com/feedback/
    http://www.apple.com/contact/feedback.html
    If you have isolated a bug with a procedure worthy of a software developer, sign up for a free developer account on http://developer.apple.com/ and report the bug here:
    http://bugreporter.apple.com/
    As this is a user to user forum answers may not come right away. Have patience, and usually someone eventually can come up with an answer. Some forums may not fit the subject line of your topic, and you are welcome to ask if you are unsure where to post a topic.
    This is the 2nd version of this tip. It was submitted on September 28, 2010 by a brody.
    Do you want to provide feedback on this User Contributed Tip or contribute your own? If you have achieved Level 2 status, visit the User Tips Library Contributions forum for more information.

  • Calling pl/sql api through multiple java threads

    Hi All,
    I need to call a pl/sql api from multiple java threads simultaneously and all thread will use same db connection.
    I want to know if all the threads will simultaneously call the pl/sql api then will the local variable inside pl/sql procedure be shared between them or they will get separate instances of variables.
    TIA

    You cannot make multiple parallel client calls over the same Oracle session handle. There is a single non-threaded/non-fibre serialised server process servicing client requests for that session. (physical process on Linux/Unix, thread in the oracle.exe process on Windows).
    Each thread on the client side, needs its very own Oracle session. Thus each thread will have a server process footprint on the server. Which could be problematic if 10 clients each starts 10 threads - as it means a 100 processes on the server are needed to service these client threads.
    Have a look at Overview of OCI Multithreaded Development in the Oracle® Call Interface Programmer's Guide for how to use the threading call interface of the OCI - as oppose to rolling your own where each thread manually needs to deal with is OCI session context.

  • Why Did My Thread Get Locked?

    I know I'm new here but can someone tell me why my thread got locked regarding the problems I have been having with upgrading my high speed internet?  It says it's being "resolved in a private support area."  But no one has contacted me to provide support.  *sigh* Why can't I just get a straight answer?

    Quantrill wrote:
    In other words....
    Don't count on anything being resolved.
    Now I wouldn't say that... it's something new they're trying out so I'd see if it helps. Just trying to make this board a bit more like other technical support boards where old posts from people are not getting necro'd or new posts being flooded with unrelated issues for what is usually a single line incident.
    As far as replying to http://forums.verizon.com/t5/High-Speed-Internet-D​SL-and-Dial/Upgrade-High-Speed-Internet/td-p/42398​... goes...
    1: DSL speeds can be provisioned often times on the spot. Verizon has automated systems which allow people with the right access to pick a speed, the PVC and DSLAM and any related equipment will provision for the speed and your line will re-synchronize once the DSLAM has the new configuration pushed. The issue with why Verizon takes forever to change the speed in many areas, such as mine where it takes a week is due to the billing system most likely. Until Billing updates their records network doesn't update the profile you're on, that way you are not seen as getting "Free speed boosts."
    2: Bandwidth on demand often comes with business connections, notably Fiber as the speed can be kicked up or down on demand and billing adjusted on the fly. Verizon Business has such a system up and they can do such a thing without killing the connection first (ADSL2+ has methods as well, same with FiOS!).
    3: Service changes should never result in a disconnect. If a disconnect occurs it needs to be resolved promptly as no one should be pulling your line from a DSL-enabled card or unprovisioning your line. Now if your line will not come up because they set the speed much too high and bursts of noise are knocking the DSLAM and modem offline before they fully synch, that could be another thing but the two pieces of equipment should train at lower speeds, not retry a bad speed if noise clears.
    ========
    The first to bring me 1Gbps Fiber for $30/m wins!

  • Understanding Java Thread Dump

    Hi,
    I was looking at the following thread dump
    Full thread dump Java HotSpot(TM) Server VM (11.0-b16 mixed mode):
    "pool-3-thread-1428" prio=10 tid=0x72b83800 nid=0x60ef waiting on condition [0x73318000..0x73318fb0]
    java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for <0x98983260> (a java.util.concurrent.SynchronousQueue$TransferStack)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198)
    at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:424)
    at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:323)
    at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:874)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:945)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)
    "MergeTask" daemon prio=10 tid=0x09454c00 nid=0x60e7 waiting for monitor entry [0x65106000..0x65106f30]
    java.lang.Thread.State: BLOCKED (on object monitor)
    at org.apache.log4j.Category.callAppenders(Category.java:201)
    - waiting to lock <0x96d90bb8> (a org.apache.log4j.spi.RootLogger)
    at org.apache.log4j.Category.forcedLog(Category.java:388)
    at org.apache.log4j.Category.log(Category.java:853)
    at sun.reflect.GeneratedMethodAccessor55.invoke(Unknown Source)
    I can see that 0x98983260 and 0x96d90bb8 are memory addresses of condition object and lock object respectively (I hope ti. But I was puzzled with [0x73318000..0x73318fb0] and [0x65106000..0x65106f30].
    What do these memory ranges indicate? Is there any documentation related to thread dump?
    In OpenJDK source code I can see following comment. But I did not understand what it means.
    // print guess for valid stack memory region (assume 4K pages); helps lock debugging
    st->print_cr("[" INTPTR_FORMAT "]", (intptr_t)last_Java_sp() & ~right_n_bits(12));
    Thanks,
    Unmesh

    Thread Dump Analysis On AIX Platform:
    http://middlewaremagic.com/weblogic/?p=4348

  • Java Threads not being released after loggin off

    Hello everyone,
    We are seeing a weird problem in our PI 7.0 box.
    Once I logout from the XI box (both ABAP and Java stck) my basis tem still sees Java threads aginst my id still open. Our system does not seem to be realeasing Java threads.
    Is this a know problem? What are the remidition steps.

    Hi,
    Are there existing HTTP sessions only?
    The following might be helpful.
    http://help.sap.com/saphelp_nw73/helpdata/en/c7/5ee440ba994fa3b187ff2f050cfe7c/content.htm
    http://wiki.sdn.sap.com/wiki/display/ERPHCM/Sessionnotendingafterlogoff
    Regards,
    Varun

  • Java threads monitoring

    I am using Java threads in my Java program, running on Windows Professional 2000. I am monitoring the threads using Windows Performance Monitor (WPM). However, even running a small Java program which creates only 2 threads, results in many (at least 10) instances of Java threads being reported by the WPM. Problem is, in WPM, there is no way to determine which threads in the WPM are the threads that I programmatically created. Any ideas on how to determine this?
    Thanks.
    Rhodie

    Hi Dmirty ,
    To handle large asynchronous message   in queues you can use  message packaging where multiple message are processed in one package . to make it applicable you have to perform these simple steps
    1. go to SXMB_ADM add one RUNTIME parameter PACKAGING and value 1
    2 GO TO transaction SXMS_BCONF set delay time 0 message count 100 messages and package size 1000 KB
    with these setting your improvement will increase .secondly also put  IN SXMB_ADM monitor category parameter QRFC_RESTART_ALLOWED TO 1
    this will automatically start your queue . Only thing you have to take care if you enable packaging them don't keep too many parallel queue i.e EO_INBOUND_PARALLEL and EO_OUTBOUND_PARALLEL should be less than 20
    Regards,
    Saurabh

Maybe you are looking for