Swing thread issu

I have a javax.swing.JFrame extended object that after running the code
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new chatUi().setVisible(true);
        });Continues to communicate with a network server over TCP and updates a table with information. By calls to System.out.println I can see that the communication with the server is succesfull but I cant update the gui. The only way i seme able to update the gui after that point is by events that are triggerd by the user and not by functions in my code.
What am I missing ?
Is the only way to work with the frame object by creating threads and running them by: SwingUtilities.invokeLater. ??
Any help would be greatly appriciated // Tomas

Hi,
A little bit of more code would be nice to see where your app don't do what it should do.
In general you should post every code that interacts with the gui into the EventDispatchThread(EDT)
a common way is to use the EventQueue as you did.
If one of your methods invokes changes on the gui you should them post on the EDT too.
If you want to look timebased for a special value or some networkoperations you can use
a Timer - in your case a javax.swing.Timer and not the java.util.Timer.
for further informations look at this tutorials :
http://java.sun.com/docs/books/tutorial/uiswing/misc/timer.html
http://java.sun.com/products/jfc/tsc/articles/timer/
An other nice way to let run longer threads posting intermediate results on the gui
is to use a SwingWorker -> javax.swing.SwingWorker
try those things
Olek

Similar Messages

  • Thread issue in jsp.....

    I understand that the j2ee container (tomcat or jrun...) creates ONE instance of the jsp page (i.e. compiled into servlet class) when the jsp page (let's say, myPage.jsp) is accessed the first time. All request for this jsp page will be done through thread.
    My questions are:
    1. If I instantiate an object (say, myObject) within the scriptlet, will the container create one instance of this object for each "jsp" thread? Or will there be only one instance of the myObject object and each "jsp" thread be running on a thread of myObject?!
    2. If I use javaBean in my jsp (i.e. use the <jsp:useBean..../> tag), I know that the container will create a new instance of the bean class. So if there are multiple request on the same jsp page, is it true that many instances of the bean will be created? And there will be no thread issue involed?!!
    Thanks!!

    When you create an instance of an object inside a scriplet using <% ... %>, that instance is local to the service) method of the servlet corresponding to the JSP. So there is no threading related issue.
    Smilar is the argument why there is not threading related issue with using <jsp:useBean>

  • Locked thread issue

    We encountered the following locked thread issue. Refer to the thread dump logs.
    Any idea on the root cause of the issue? It seens to us that it is the weblogic app server codes that are causing the locked threads.
    Will appreciate any advise.
    "ExecuteThread: '0' for queue: 'weblogic.socket.Muxer'" id=22 idx=0x50 tid=329 prio=5 alive, in native, blocked, daemon
    -- Blocked trying to get lock: java/lang/String@0x9a73910[fat lock]
    at jrockit/vm/Threads.waitForUnblockSignal()V(Native Method)
    at jrockit/vm/Locks.fatLockBlockOrSpin(Locks.java:1674)[optimized]
    at jrockit/vm/Locks.lockFat(Locks.java:1775)[optimized]
    at jrockit/vm/Locks.monitorEnterSecondStageHard(Locks.java:1311)[optimized]
    at jrockit/vm/Locks.monitorEnterSecondStage(Locks.java:1258)[optimized]
    at jrockit/vm/Locks.monitorEnter(Locks.java:2455)[optimized]
    at weblogic/socket/EPollSocketMuxer.processSockets(EPollSocketMuxer.java:153)
    at weblogic/socket/SocketReaderRequest.run(SocketReaderRequest.java:29)
    at weblogic/socket/SocketReaderRequest.execute(SocketReaderRequest.java:42)
    at weblogic/kernel/ExecuteThread.execute(ExecuteThread.java:145)
    at weblogic/kernel/ExecuteThread.run(ExecuteThread.java:117)
    at jrockit/vm/RNI.c2java(IIIII)V(Native Method)
    -- end of trace
    "ExecuteThread: '2' for queue: 'weblogic.socket.Muxer'" id=24 idx=0x58 tid=331 prio=5 alive, in native, blocked, daemon
    -- Blocked trying to get lock: java/lang/String@0x9a73910[fat lock]
    at jrockit/vm/Threads.waitForUnblockSignal()V(Native Method)
    at jrockit/vm/Locks.fatLockBlockOrSpin(Locks.java:1674)[optimized]
    at jrockit/vm/Locks.lockFat(Locks.java:1775)[optimized]
    at jrockit/vm/Locks.monitorEnterSecondStageHard(Locks.java:1311)[optimized]
    at jrockit/vm/Locks.monitorEnterSecondStage(Locks.java:1258)[optimized]
    at jrockit/vm/Locks.monitorEnter(Locks.java:2455)[optimized]
    at weblogic/socket/EPollSocketMuxer.processSockets(EPollSocketMuxer.java:153)
    at weblogic/socket/SocketReaderRequest.run(SocketReaderRequest.java:29)
    at weblogic/socket/SocketReaderRequest.execute(SocketReaderRequest.java:42)
    at weblogic/kernel/ExecuteThread.execute(ExecuteThread.java:145)
    at weblogic/kernel/ExecuteThread.run(ExecuteThread.java:117)
    at jrockit/vm/RNI.c2java(IIIII)V(Native Method)
    -- end of trace
    "ExecuteThread: '1' for queue: 'weblogic.socket.Muxer'" id=23 idx=0x54 tid=330 prio=5 alive, in native, daemon
    at jrockit/ext/epoll/EPoll.epollWait0(IIII)I(Native Method)
    at jrockit/ext/epoll/EPoll.epollWait(EPoll.java:103)
    at weblogic/socket/EPollSocketMuxer.processSockets(EPollSocketMuxer.java:156)
    ^-- Holding lock: java/lang/String@0x9a73910[fat lock]
    at weblogic/socket/SocketReaderRequest.run(SocketReaderRequest.java:29)
    at weblogic/socket/SocketReaderRequest.execute(SocketReaderRequest.java:42)
    at weblogic/kernel/ExecuteThread.execute(ExecuteThread.java:145)
    at weblogic/kernel/ExecuteThread.run(ExecuteThread.java:117)
    at jrockit/vm/RNI.c2java(IIIII)V(Native Method)
    -- end of trace

    This is standard behavior for the socket muxer threads. Only one of the epoll muxer threads is actually holding the lock at any one time. Here is the output of part of my thread dump on Linux with WLS 10.3.4 on JRockit on startup. The server is not hung up at all. Make a request on the server and take another thread dump and you'll see the lock change.
    1st dump with ExecuteThread 1 waiting to get the lock from ExecuteThread 2
    "ExecuteThread: '1' for queue: 'weblogic.socket.Muxer'" id=25 idx=0x58 tid=26836 prio=5 alive, blocked, native_blocked, daemon
        -- Blocked trying to get lock: java/lang/String@0xe82d6ec0[thin lock]
        at jrockit/vm/Threads.sleep(I)V(Native Method)
        at jrockit/vm/Locks.waitForThinRelease(Locks.java:955)
        at jrockit/vm/Locks.monitorEnterSecondStageHard(Locks.java:1083)
        at jrockit/vm/Locks.monitorEnterSecondStage(Locks.java:1005)
        at jrockit/vm/Locks.monitorEnter(Locks.java:2179)
        at weblogic/socket/EPollSocketMuxer.processSockets(EPollSocketMuxer.java:153)
        at weblogic/socket/SocketReaderRequest.run(SocketReaderRequest.java:29)
        at weblogic/socket/SocketReaderRequest.execute(SocketReaderRequest.java:42)
        at weblogic/kernel/ExecuteThread.execute(ExecuteThread.java:145)
        at weblogic/kernel/ExecuteThread.run(ExecuteThread.java:117)
        at jrockit/vm/RNI.c2java(IIIII)V(Native Method)
        -- end of trace
    "ExecuteThread: '2' for queue: 'weblogic.socket.Muxer'" id=26 idx=0x5c tid=26837 prio=5 alive, in native, daemon
        at jrockit/ext/epoll/EPoll.epollWait0(ILjava/nio/ByteBuffer;II)I(Native Method)
        at jrockit/ext/epoll/EPoll.epollWait(EPoll.java:115)
        at weblogic/socket/EPollSocketMuxer.processSockets(EPollSocketMuxer.java:156)
        ^-- Holding lock: java/lang/String@0xe82d6ec0[thin lock]
        at weblogic/socket/SocketReaderRequest.run(SocketReaderRequest.java:29)
        at weblogic/socket/SocketReaderRequest.execute(SocketReaderRequest.java:42)
        at weblogic/kernel/ExecuteThread.execute(ExecuteThread.java:145)
        at weblogic/kernel/ExecuteThread.run(ExecuteThread.java:117)
        at jrockit/vm/RNI.c2java(IIIII)V(Native Method)
        -- end of trace2nd dump after the server servers a request with ExecuteThread 2 waiting to get the lock from ExecuteThread 1
    "ExecuteThread: '1' for queue: 'weblogic.socket.Muxer'" id=25 idx=0x58 tid=26836 prio=5 alive, in native, daemon
        at jrockit/ext/epoll/EPoll.epollWait0(ILjava/nio/ByteBuffer;II)I(Native Method)
        at jrockit/ext/epoll/EPoll.epollWait(EPoll.java:115)
        at weblogic/socket/EPollSocketMuxer.processSockets(EPollSocketMuxer.java:156)
        ^-- Holding lock: java/lang/String@0xe82d6ec0[fat lock]
        at weblogic/socket/SocketReaderRequest.run(SocketReaderRequest.java:29)
        at weblogic/socket/SocketReaderRequest.execute(SocketReaderRequest.java:42)
        at weblogic/kernel/ExecuteThread.execute(ExecuteThread.java:145)
        at weblogic/kernel/ExecuteThread.run(ExecuteThread.java:117)
        at jrockit/vm/RNI.c2java(IIIII)V(Native Method)
        -- end of trace
    "ExecuteThread: '2' for queue: 'weblogic.socket.Muxer'" id=26 idx=0x5c tid=26837 prio=5 alive, blocked, native_blocked, daemon
        -- Blocked trying to get lock: java/lang/String@0xe82d6ec0[fat lock]
        at jrockit/vm/Threads.waitForUnblockSignal()V(Native Method)
        at jrockit/vm/Locks.fatLockBlockOrSpin(Locks.java:1411)
        at jrockit/vm/Locks.lockFat(Locks.java:1512)
        at jrockit/vm/Locks.monitorEnterSecondStageHard(Locks.java:1054)
        at jrockit/vm/Locks.monitorEnterSecondStage(Locks.java:1005)
        at jrockit/vm/Locks.monitorEnter(Locks.java:2179)
        at weblogic/socket/EPollSocketMuxer.processSockets(EPollSocketMuxer.java:153)
        at weblogic/socket/SocketReaderRequest.run(SocketReaderRequest.java:29)
        at weblogic/socket/SocketReaderRequest.execute(SocketReaderRequest.java:42)
        at weblogic/kernel/ExecuteThread.execute(ExecuteThread.java:145)
        at weblogic/kernel/ExecuteThread.run(ExecuteThread.java:117)
        at jrockit/vm/RNI.c2java(IIIII)V(Native Method)
        -- end of traceHere is a blog on this topic: http://jojovedder.blogspot.com/2009/05/weblogic-socket-muxers-are-not-stuck.html

  • Killing a Swing thread

    Hello,
    How can I kill a Swing thread? For example the program below would never exit. Sure you can type System.exit(0) which would exit anything, but what are the other solutions?
    I tried putting chooser = null;
    System.gc();in the end of main() but this won&#8217;t work.
    To formulate my question better - how would I kill a thread I do not have complete command of (i.e. I can&#8217;t do usual do/while thread stopping)?
    Big thanks in advance.
    public class SwingLiveTest{
        public static void main(String[] args) {
            JFileChooser chooser = new JFileChooser();
            if (chooser.showSaveDialog(null) != JFileChooser.APPROVE_OPTION) return;
            File file = chooser.getSelectedFile();
            System.out.println(file);
            /*chooser = null;
            System.gc(); */

    You can't kill any Thread like this, at least not those where there is no method to call.
    It is possible to cause a Thread to stop, call the stop method, however this is not the recommended approach for very good reasons (Read the JavaDocs for java.lang.Thread.stop() method to see why.
    It should be possible, once you have obtained a reference to the Thread you wish to stop, to call interrupt() on that Thread.
    This is not guaranteed to work because you are dependent on the implementation of the Thread class you are manipulating or the Runnable that the Thread instance is currently running.
    There may be classes in the com.sun packages which can aid you with this problem, this is where Sun usually sticks undocumented implementation however these packages are not officially supported and there is no guarantee that classes you use in one VM are available in another, in particular when the VM you are using is not a Sun VM.

  • In this case, can I modify swing GUI out of swing thread?

    I know the Swing single thread rule and design (Swing is not thread safe).
    For time-consuming task, we are using other thread to do the task and
    we use SwingUtilities.invokeAndWait() or SwingUtilities.invokeLater (or SwingWorker) to update Swing GUI.
    My problem is, my time-consuming task is related to Swing GUI stuff
    (like set expanded state of a huge tree, walk through entire tree... etc), not the classic DB task.
    So my time-consuming Swing task must executed on Swing thread, but it will block the GUI responsivity.
    I solve this problem by show up a modal waiting dialog to ask user to wait and
    also allow user to cancel the task.
    Then I create an other thread (no event-dispatch thread) to do my Swing time-consuming tasks.
    Since the modal dialog (do nothing just allow user to cancel) is a thread spawn by
    Swing event-dispatch thread and block the Swing dispatch-thread until dialog close.
    So my thread can modify Swing GUI stuff safely since there are no any concurrent access problem.
    In this case, I broke the Swing's suggestion, modify Swing stuff out of Swing event-dispatch thread.
    But as I said, there are no concurrent access, so I am safe.
    Am I right? Are you agree? Do you have other better idea?
    Thanks for your help.

    If you drag your modal dialog around in front of the background UI, then there is concurrent access: paint requests in your main window as the foreground window moves around.

  • Problem Deploying Composites to Oracle SOA 11.1.1.5 (STUCK Thread Issue)

    Hi All,
    I got stuck thread issues when deploying composites to Oracle SOA 11.1.1.5 running on Windows Server 2008 R2. Even the SimpleApproval composite which ships with the standard installation is having trouble deploying.
    The composites are deploying fine in Oracle SOA 11.1.1.5 running on Windows XP.
    I'm not so good with thread dumps, so I post it below for rescue.
    Please advice,
    Rommel
    <Jul 18, 2011 10:15:25 AM AST> <Error> <WebLogicServer> <BEA-000337> <[STUCK] Ex
    ecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)' has been bus
    y for "605" seconds working on the request "weblogic.servlet.internal.ServletReq
    uestImpl@32d047d4[
    POST /soa-infra/deployer HTTP/1.1
    Connection: TE
    TE: trailers, deflate, gzip, compress
    User-Agent: Oracle HTTPClient Version 10h
    Accept-Encoding: gzip, x-gzip, compress, x-compress
    ECID-Context:
    Authorization: Basic bmFnaGl3ZWJsb2dpY3NvYTp3ZWJsb2dpY3NvYTEwIQ==
    Content-type: application/octet-stream
    Content-Length: 25876
    ]", which is more than the configured time (StuckThreadMaxTime) of "600" seconds
    . Stack trace:
    Thread-55 "[STUCK] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-
    tuning)'" <alive, in native, suspended, priority=1, DAEMON> {
    jrockit.net.SocketNativeIO.readBytesPinned(SocketNativeIO.java:???)
    jrockit.net.SocketNativeIO.socketRead(SocketNativeIO.java:24)
    java.net.SocketInputStream.socketRead0(SocketInputStream.java:???)
    java.net.SocketInputStream.read(SocketInputStream.java:107)
    oracle.net.nt.MetricsEnabledInputStream.read(TcpNTAdapter.java:707)
    oracle.net.ns.Packet.receive(Packet.java:243)
    oracle.net.ns.DataPacket.receive(DataPacket.java:106)
    oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:309)
    oracle.net.ns.NetInputStream.read(NetInputStream.java:254)
    oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrap
    per.java:93)
    oracle.jdbc.driver.T4CMAREngine.getNBytes(T4CMAREngine.java:1573)
    oracle.jdbc.driver.T4C8TTILobd.unmarshalLobData(T4C8TTILobd.java:360)
    oracle.jdbc.driver.T4C8TTILob.readLOBD(T4C8TTILob.java:787)
    oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:303)
    oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:181)
    oracle.jdbc.driver.T4C8TTILob.read(T4C8TTILob.java:139)
    oracle.jdbc.driver.T4CConnection.getBytes(T4CConnection.java:2690)
    ^-- Holding lock: oracle.jdbc.driver.T4CConnection@32386377[thin lock]
    oracle.sql.BLOB.getBytes(BLOB.java:557)
    oracle.jdbc.driver.OracleBlobInputStream.needBytes(OracleBlobInputStream.jav
    a:188)
    oracle.jdbc.driver.OracleBufferedStream.readInternal(OracleBufferedStream.ja
    va:171)
    oracle.jdbc.driver.OracleBufferedStream.read(OracleBufferedStream.java:151)
    ^-- Holding lock: oracle.jdbc.driver.OracleBlobInputStream@341d0b87[thin loc
    k]
    java.io.BufferedInputStream.fill(BufferedInputStream.java:189)
    java.io.BufferedInputStream.read(BufferedInputStream.java:236)
    ^-- Holding lock: oracle.mds.internal.persistence.db.DBInputStream@341d0bb2[
    thin lock]
    oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:363)
    oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:230)
    oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:217)
    oracle.fabric.common.wsdl.SchemaBuilder.parseXMLSrc(SchemaBuilder.java:1016)
    oracle.fabric.common.wsdl.SchemaBuilder.parseXSDSrc(SchemaBuilder.java:984)
    oracle.fabric.common.wsdl.SchemaBuilder.processSchemaImportsAndInclude(Schem
    aBuilder.java:755)
    oracle.fabric.common.wsdl.SchemaBuilder.loadEmbeddedSchemas(SchemaBuilder.ja
    va:474)
    oracle.fabric.common.wsdl.SchemaBuilder.loadSchemasFromWSDL(SchemaBuilder.ja
    va:423)
    oracle.fabric.common.wsdl.SchemaBuilder.loadAllSchemas(SchemaBuilder.java:21
    4)
    oracle.fabric.common.wsdl.SchemaManager.loadAllXSD(SchemaManager.java:209)
    ^-- Holding lock: oracle.fabric.common.wsdl.SchemaManager@36279195[thin lock
    oracle.fabric.common.wsdl.SchemaManager.getXSDEntityResolver(SchemaManager.j
    ava:424)
    oracle.fabric.composite.model.CompositeModel.loadImports(CompositeModel.java
    :361)
    oracle.fabric.composite.model.CompositeModel.getWSDLManager(CompositeModel.j
    ava:196)
    oracle.integration.platform.blocks.adapter.AbstractAdapterBindingComponent.g
    etWSDLDefinition(AbstractAdapterBindingComponent.java:168)
    oracle.integration.platform.blocks.adapter.AdapterReference.loadDefinition(A
    dapterReference.java:543)
    oracle.integration.platform.blocks.adapter.AdapterReference.load(AdapterRefe
    rence.java:377)
    oracle.integration.platform.blocks.adapter.AdapterReference.load(AdapterRefe
    rence.java:73)
    oracle.integration.platform.blocks.deploy.CompositeDeploymentConnection.depl
    oyReferences(CompositeDeploymentConnection.java:177)
    oracle.integration.platform.blocks.deploy.CompositeDeploymentConnection.depl
    oy(CompositeDeploymentConnection.java:81)
    oracle.integration.platform.blocks.deploy.CompositeDeploymentManagerImpl.ini
    tDeployment(CompositeDeploymentManagerImpl.java:143)
    oracle.integration.platform.blocks.deploy.CompositeDeploymentManagerImpl.loa
    d(CompositeDeploymentManagerImpl.java:61)
    sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:?
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:27
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
    .java:25)
    java.lang.reflect.Method.invoke(Method.java:575)
    org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopU
    tils.java:306)
    org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint
    (ReflectiveMethodInvocation.java:182)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Reflect
    iveMethodInvocation.java:148)
    oracle.integration.platform.blocks.deploy.DeploymentEventPublisher.invoke(De
    ploymentEventPublisher.java:57)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Reflect
    iveMethodInvocation.java:148)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopPro
    xy.java:151)
    $Proxy309.load(Unknown Source)
    oracle.integration.platform.blocks.deploy.StandaloneCompositeDeploymentCoord
    inatorImpl.coordinateCompositeDeployment(StandaloneCompositeDeploymentCoordinato
    rImpl.java:54)
    oracle.integration.platform.blocks.deploy.servlet.BaseDeployProcessor.deploy
    NewComposite(BaseDeployProcessor.java:365)
    oracle.integration.platform.blocks.deploy.servlet.BaseDeployProcessor.deploy
    SARs(BaseDeployProcessor.java:123)
    ^-- Holding lock: java.lang.Object@3621c97c[thin lock]
    oracle.integration.platform.blocks.deploy.servlet.DeployProcessor.doDeployWo
    rk(DeployProcessor.java:122)
    oracle.integration.platform.blocks.deploy.servlet.DeployProcessor.doDeployWo
    rk(DeployProcessor.java:107)
    oracle.integration.platform.blocks.deploy.servlet.DeployProcessor.doDeploy(D
    eployProcessor.java:96)
    oracle.integration.platform.blocks.deploy.servlet.DeployProcessor.process(De
    ployProcessor.java:68)
    oracle.integration.platform.blocks.deploy.servlet.CompositeDeployerServlet.d
    oPostInsideLoggingSession(CompositeDeployerServlet.java:141)
    oracle.integration.platform.blocks.deploy.servlet.CompositeDeployerServlet.d
    oPost(CompositeDeployerServlet.java:119)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:700)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:815)
    weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSe
    curityHelper.java:224)
    weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelpe
    r.java:108)
    weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:206)
    weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:55)
    oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
    oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:299)
    oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java
    :405)
    oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
    oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:98)
    oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:70)
    weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:55)
    oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
    oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:299)
    oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java
    :405)
    oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
    oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:98)
    oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:70)
    weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:55)
    oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:86)
    weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:55)
    weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapR
    un(WebAppServletContext.java:3687)
    weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(W
    ebAppServletContext.java:3681)
    weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubjec
    t.java:308)
    weblogic.security.service.SecurityManager.runAs(SecurityManager.java:116)
    weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletC
    ontext.java:2213)
    weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.
    java:2135)
    weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:142
    0)
    weblogic.work.ExecuteThread.execute(ExecuteThread.java:203)
    weblogic.work.ExecuteThread.run(ExecuteThread.java:170)
    >

    I just noted that this is a database connectivity issue because when I point my soa related data sources (mds, soa_infra, etc...)to a local xe database, the deployment is doing fine.

  • Need help about Thread issue

    Given from scjp
    1.public static void main(String[] args) {
    2.        NameRunnable nr = new NameRunnable();
    3.        Thread t1 = new Thread(nr);              
    4.        t1.start();
    5.        t1.join();                   
    }There are some questions which i made up myself to test how i understand about the thread issue and I really need some experts to confirm about it.
    Question 1: At line 3, how many threads we have now ?
    my answer is
    there are 2 threads. the first one is main thread and the second one is t.
    I am not sure about the t thread because in the book, they indicate that after instantiating the thread,
    we just have a thread object but not a true thread.
    Question 2: At line 4, after t1.start(), which thread will be executed first.
    My answer is
    we dont know because it depends on the scheduler.
    Question 3: what t1.join() does ?
    my answer is
    blablabla.What I am thinking is t.join() joins the current thread to the end of t so that when t finishes the current thread can run again. However, which one is the current thread now. That is why I am stuck
    Please help me. I appreciate
    Edited by: newbie on Nov 25, 2010 4:46 PM
    Edited by: newbie on Nov 25, 2010 4:47 PM
    Edited by: newbie on Nov 25, 2010 4:49 PM

    newbie wrote:
    Given from scjp
    public static void main(String[] args) {
    NameRunnable nr = new NameRunnable();
    Thread t1 = new Thread(nr);              
    t1.start();
    t1.join();                   
    }There are some questions which i made up myself to test how i understand about the thread issue and I really need some experts to confirm about it.
    Question 1: At line 3, how many threads we have now ?
    my answer is
    there are 2 threads. the first one is main thread and the second one is t.
    I am not sure about the t thread because in the book, they indicate that after instantiating the thread,
    we just have a thread object but not a true thread.
    Don't use code blocks for prose. It won't autowrap and can lead to display problems if a line is too long.
    Which is line 3?
    What do you mean by "how many threads to we have?" Do you mean how many Thread objects exist, or how many threads (lower case "t") are executing.
    After you have called t1.start(), there are at least 2 threads executing--the main thread, and the one you started. I say "at least" because the JVM has some administrative threads of its own.
    Question 2: At line 4, after t1.start(), which thread will be execute first.
    My answer is
    we dont know because it depends on the scheduler.
    Correct. And don't think of one executing "first." They can take turns, or they can both execute at the same time (if you have a multicore or multi-CPU machine).
    Question 3: what t1.join() does ?
    my answer is
    blablabla.What I am thinking is t.join() joins the current thread to the end of t so that when t finishes the current thread can run again. However, which one is the current thread now. That is why I am stuck
    Please help me. I appreciateDid you read [url http://download.oracle.com/javase/6/docs/api/java/lang/Thread.html#join()]the docs for join()? They tell you exactly what it does. If you don't understand after reading, post again.

  • JMeter +JSF 1.2 +Multiple threads issue

    I have an issue when running JMeter with an JSF 1.2 application.
    I have the regex and xpath fix working. It is extracting the correct ViewState value, but only as long as I am running one thread. If I start a thread group with multiple threads the regex/xpath will eventually return the default value and the test will fail.
    Scenario 1 (SUCCESS):
    I run one thread and one thread group, regex/xpath return the
    "ViewState" value correctly and the test runs perfectly until I stop it.
    Scenario 2 (FAILURE):
    I run multiple threads and one thread group, regex/xpath
    eventually return the DEFAULT value instead the "ViewState" value to
    all but one thread. The more threads the faster they fail. It really
    seems like there is a threading issue.
    Has anyone experienced similar issues when running regex/xpath and multiple threads?

    Thank you, I tried what you suggested and revealed something interesting. The application in some cases prints the following on the screen:
    *~com.sun.faces.saveStateFieldMarker~*, and it is in those cases JMETER Xpath extraction fails.
    Well I have to look more into it. Thank again for the help.

  • Thread issue...please clarify

    I am kind of new in Servlet/JSP world.
    I have a servlet and it gets the information from the database and put the information in a bean . In the servlet, the bean is placed in session object. The code is as follows:
    doPost(......)
    HttpSession session = req.getSession(true);
    //Here session is local variable to doPost()
    session.setAttribute("name", databean);
    //databean is the bean created by servlet inside doPost()
    //Then sendRedirect to a JSP page to show the information from the bean.
    The JSP retrives the values as bellow:
    <jsp:useBean id="name" class="common.Databean"
         scope="session" />
    <%
              //Get the information from the bean               
              Rowbean [] rows = name.getRows();
              for(int x = 0; x < rows.length ; x++)
              String description = rows[x].getDescription();
              String category_ident = rows[x].getCategory_ident();
    %>
    My question is :
    Is there any safe threading issue in this procedure..to be specific is that session object is accessable by any other client calling same time the servlet..
    Any explanation will be appreciated.
    Shakilc

    It is quite possible that the session can be accessed by two threads. This would be the case if the user accesses your servlet from two browser windows (or tabs). Browsers have different behaviors with regard to interacting with your application sessions. For example, two IE windows will be treated as two sessions, whereas, two Netscape tabs (not windows) will be treated as a single session. This behavior is browser specific. So, it is quite likely that you may be have two threads accessing your session at the same time. The session implementation is typically synchronized, so that two or more threads cannot modify a session value at the same time, but, one thread can immediately overwrite a value stored by another thread. This is normal behavior and typically acceptable behavior.
    Hope this answers your question.
    Sonny

  • Deadlock with thread issues while generating reports with Crystal Report XI

    We are facing deadlock with thread issues while generating report with Crystal Report XI
    Version Number is 11.0 and the database used is Oracle
    In the log file on line number 74350  by 2008/12/16 13:35:54 there is a dead lock with Thread: u20184u2019 is waiting to acquire lock for 'com.crystaldecisions.reports.queryengine.av@15214b9' which is held by the Thread: '0'.
    And  a dead lock with Thread: u20180u2019 is waiting to acquire lock for 'com.crystaldecisions.reports.queryengine.av@15214b9' which is held by the Thread: '4'.
    Exactly after 10 minutes we can see the thread 4 and 0 are declared as STUCK by 2008/12/16  13:45:54 .
    Is this an existing issue with Crystal Report?
    Is there some solution for this problem?
    THE LOG FILE INFORMATION IS GIVEN BELOW
    [deadlocked thread] [ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)':
    Thread '[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'' is waiting to acquire lock 'com.crystaldecisions.reports.queryengine.av@15214b9' that is held by thread '[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)''
    Stack trace:
         com.crystaldecisions.reports.queryengine.av.V(Unknown Source)
         com.crystaldecisions.reports.queryengine.av.do(Unknown Source)
         com.crystaldecisions.reports.queryengine.as.if(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.datainterface.j.c(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.datainterface.j.a(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.datainterface.j.a(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.cy.b(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.cy.long(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.a1.o(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.a1.a(Unknown Source)
         com.crystaldecisions.reports.common.ab.a(Unknown Source)
         com.crystaldecisions.reports.common.ab.if(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.a1.if(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.a1.o(Unknown Source)
         com.crystaldecisions.reports.reportengineinterface.a.a(Unknown Source)
         com.crystaldecisions.reports.reportengineinterface.a.a.b.a(Unknown Source)
         com.crystaldecisions.reports.sdk.ReportClientDocument.open(Unknown Source)
         com.sysarris.aris.crystalreports.RepServlet.generateReport(RepServlet.java:65)
         com.sysarris.aris.crystalreports.RepServlet.doPost(RepServlet.java:40)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
         weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
         weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:272)
         weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:165)
         weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3153)
         weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1973)
         weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1880)
         weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1310)
         weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
         weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
    [deadlocked thread] [ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)':
    Thread '[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'' is waiting to acquire lock 'com.crystaldecisions.reports.queryengine.av@12e0415' that is held by thread '[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)''
    Stack trace:
         com.crystaldecisions.reports.queryengine.av.V(Unknown Source)
         com.crystaldecisions.reports.queryengine.av.do(Unknown Source)
         com.crystaldecisions.reports.queryengine.as.if(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.datainterface.j.c(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.datainterface.j.a(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.datainterface.j.a(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.cy.b(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.cy.long(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.a1.o(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.a1.a(Unknown Source)
         com.crystaldecisions.reports.common.ab.a(Unknown Source)
         com.crystaldecisions.reports.common.ab.if(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.a1.if(Unknown Source)
         com.crystaldecisions.reports.reportdefinition.a1.o(Unknown Source)
         com.crystaldecisions.reports.reportengineinterface.a.a(Unknown Source)
         com.crystaldecisions.reports.reportengineinterface.a.a.b.a(Unknown Source)
         com.crystaldecisions.reports.sdk.ReportClientDocument.open(Unknown Source)
         com.sysarris.aris.crystalreports.RepServlet.generateReport(RepServlet.java:65)
         com.sysarris.aris.crystalreports.RepServlet.doPost(RepServlet.java:40)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
         weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
         weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:272)
         weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:165)
         weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3153)
         weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1973)
         weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1880)
         weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1310)
         weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
         weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
    Can you please suggest any work around for this?

    I'm not referring to Servlet threading issues.
    I'll clarify.
    You have two threads, both entering ReportClientDocument.open(...) method.
    Thread 4 is waiting to acquire 'com.crystaldecisions.reports.queryengine.av@15214b9'
    Thread 0 is waiting to acquire ''com.crystaldecisions.reports.queryengine.av@12e0415'
    So I'm thinking ??? are they the same objects?
    My specific question concerning the ReportClientDocument is that both are calling open - i.e., trying to open a new report.  You wouldn't be trying to open different reports using the same ReportClientDocument - so was wondering if you've cached the RCD and trying to open two different reports at the same time on the same instance via different threads.
    You'd normally tie a ReportClientDocument instance to a HTTP Session, to ensure each user gets their own copy.
    Sincerely,
    Ted Ueda

  • JPS thread issues and Tag Libs

    I was curious as to the thread issues with using Tag Libs inside of JPS'.
    I realize that many threads can access an individual JSP and that a JSP (at least in tomcat) uses the same instance of its tag over and over again.
    But I have the following questions:
    Are there thread race issues with using tags?
    If there are thread race issues wouldn't it be a bad idea to use the setter methods on a tag or have any instance level variables in a tag?
    Is the access to the tag synchronized in the creation of the JSP/Servlet?
    Thanks for your time,
    Nate

    I actually decompiled the JSP that was created by tomcat and it (the complied JSP) is actually using a factory to get an instance of a tag. When the complied JSP is done with the Tag instance it calls the release() method on the Tag and then the factory is allowed to reuse that Tag.
    So, basically when Tags are used like they are supposed to be, there are no threading/race issues.
    I have downloaded the Tag specs, but haven't been able to read them yet. After I do get the chance to read them, I will try and post my findings.

  • Java swing and threading issue

    i am trying to update swing components from some thread. at my first try, i noticed this was a disaster. upon further research, i found out about the single-threaded model of swing events (i.e. event dispatching thread).
    i did more research and could NOT find a good example on how to update swing components from other threads. many examples were showing too much.
    can someone post a simple example on here? i just want to see how to properly update a swing component from a non-swing class using threading.

    I think its a simple example:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=621226
    Let us know what you think.

  • PaintChat GUI thread issue using Swing

    Hi there, I'm making a paintchat program for fun and have gotten it to work locally but now I would like to add the networking parts in. I have a function like this in a class called Util:
    public static NewscastMessage sendMessage(NewscastMessage message, int srcID, IPeerDescriptor dstPeer) {
    System.out.println("sending message");
    NewscastMessage replyMessage = null;
    String errorMessage = null;
    try {
    Socket socket = new Socket(dstPeer.getAddress(), dstPeer.getPortNumber());
    socket.setSoTimeout(5 * 1000); // timeout to 30 seconds
    ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
    ObjectInputStream in = new ObjectInputStream(socket.getInputStream());
    out.writeObject(message);
    replyMessage = (NewscastMessage)in.readObject();
    out.close();
    in.close();
    socket.close();
    return replyMessage;
    } catch (ConnectException ex) {
    Logger.getLogger(PeerClient.class.getName()).log(Level.SEVERE, ex.getMessage());
    errorMessage = ex.getMessage();
    } catch (SocketTimeoutException ex) {
    Logger.getLogger(PeerClient.class.getName()).log(Level.SEVERE, ex.getMessage());
    errorMessage = ex.getMessage();
    } catch (IOException ex) {
    Logger.getLogger(PeerClient.class.getName()).log(Level.SEVERE, ex.getMessage());
    errorMessage = ex.getMessage();
    } catch (ClassNotFoundException ex) {
    Logger.getLogger(PeerClient.class.getName()).log(Level.SEVERE, ex.getMessage());
    errorMessage = ex.getMessage();
    } catch (RuntimeException ex) {
    Logger.getLogger(PeerClient.class.getName()).log(Level.SEVERE, ex.getMessage());
    errorMessage = ex.getMessage();
    return new NewscastError(srcID, "While trying to send a message to the Peer with id [ " +
    dstPeer.getId() + " ] that has the ip address " + dstPeer.getAddress() + ". \nException on peer " + srcID + ": " + errorMessage);
    Essentially when a user types a message into a text field and presses enter, I catch the event and append the text into a text area locally then afterwards I'd like to send this message to a peer via Util.sendMessage. When it gets to this sending part, this error occurs:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    I thought it might be some issues with the event lock and surrounded the call to sendMessage with a synchronize block and didn't work. Any ideas? Thanks in advance.

    Sorry forgot to attach the later part:
    private void sendTextToDestination(String text){
    // send via socket
    synchronized (this) {
    IPeerDescriptor dst = _peer.getPartialView().getOwnerPeerDescriptor();
    NewscastText message = new NewscastText(_peer.getPortNumber(), text);
    NewscastMessage replyMessage = null;
    replyMessage = Util.sendMessage((NewscastMessage) message, _peer.getPortNumber(), dst);
    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
    String newline = "\n";
    String text = jTextField1.getText();
    jTextArea1.append(text + newline);
    jTextField1.selectAll(); // after pressing enter, highlight text
    //Make sure the new text is visible, even if there
    //was a selection in the text area.
    jTextArea1.setCaretPosition(jTextArea1.getDocument().getLength());
    synchronized(this){
    sendTextToDestination(text); -------> this is where the error occurs
    }

  • Threading issue in swing

    From my JDialog(modal ) I am making a RMI call to other machine, this RMI call takes lot of time, so what i
    need is a way to provide user the option of cancelling the task in between. i.e. after invoking
    the call, immediately another dialog should come with the cancel option.
    How can we achieve this? Do we need to use threads for it.
    Thanks in advance

    Search for this site for info on class "SwingWorker" (not part of the SDK). Subclassing SwingWorker allows you to create interruptable background tasks.

  • Hi Guys! Will you share your thoughts on a Thread issue?

    Hi! I am working on figuring out how to get my application to use threads to enable the simultaneous movement of (n) balls across the JFrame area. The task is to enable the user to click on the application and with each click a new ball should be created as a Thread and then it should bounce back and forth across the screen.
    I have been working on this now for a couple of days. It would be really great if one of you guys could help me! :-)
    Here are my specific issues:
    I am using the mousePressed() method to generate the data needed to instantiate a Ball object. However, I cannot get it to work as a Thread.
    I tried calling the start() method on it but all that happens is the application stays blank.
    I cannot get this thing to work -and I really need to make it work today -- Please --- is there a sweetheart out there who will take a minute to help? ;-)
    Jennifer
    My code is below:
    Balls.java
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Balls extends JFrame implements MouseListener
          private int x, y, r, g, b;//Variables to hold x,y and color values
          private Vector basketOBalls;//Hold all of the Ball objects (and Threads created)
          private Ball ballFactory;//Ball objects created here
            Method Name: Balls()
            Return Value: none
            Input Parameters: None
            Method Description: Constructor
          public Balls()
            //call to super for Title of app
            super( " Bouncing Balls " );
            //Listen for mouse events
            addMouseListener( this ); 
            //instantiate the basketOBalls object
            basketOBalls = new Vector(20);
                //Set Initial JFrame Window Size
            setSize( 400, 400 );
         //Show it!
         show();
         }//EOConstructor
            Method Name: mousePressed(MouseEvent e)
            Return Value: none
            Input Parameters: MouseEvent
            Method Description: This takes the info from the users
            mouse click and creates a new Ball Object and then adds it
            to the basketOBalls Vector. Presently, it (incorrectly?) also
            calls the repaint() method in order to draw the ball to the
            screen.
           public void mousePressed( MouseEvent e )
               x = e.getX();//set x value
               y = e.getY();//set y value
               r = 1 + (int) ( 254 * Math.random() );//set red value
               g = 1 + (int) ( 254 * Math.random() );//set green value
               b = 1 + (int) ( 254 * Math.random() );//set blue value
               Color colorin = new Color( r, g, b );
               ballFactory = new Ball( x, y, colorin );
               //new Thread(ballFactory).start(); //This is the Problem area!!!!!!!!!!!!!!!!!!!!!
               basketOBalls.addElement( ballFactory );
               repaint();
            }//EOmP
            Method Name: paint( Graphics g )
            Return Value: none
            Input Parameters: Graphics Object g
            Method Description: Walk through the Vector to
            explicitly cast each object back as a Ball and
            then calls the Ball draw() and ball move() methods
            in order to make the balls move on the screen.
        public void paint( Graphics g )
            Ball b;
            for( int i = 0; i < basketOBalls.size(); i++)
               b = (Ball) (basketOBalls.elementAt(i));
               b.draw(g);
               b.move();
            }//EOFor
          }//EOpaint
            Method Name: main()
            Return Value: none
            Input Parameters: String args[]
            Method Description: This makes it all go.
          public static void main( String args[] )
            Balls app = new Balls();
            app.addWindowListener(
              new WindowAdapter()
                     public void windowClosing( WindowEvent e )
                                    System.exit(0);
                     }//EOwindowClosing Method
              }//EOWindowAdapter Method
              );//EOaddWindowListener Argument
          }//EOMain
        public void mouseClicked( MouseEvent e ) { }
        public void mouseReleased( MouseEvent e ) { }
        public void mouseEntered( MouseEvent e ) { }
        public void mouseExited( MouseEvent e ) { }
    }//EOFBall.java
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Ball extends JFrame //implements Runnable
            public static final int APP_SIZE = 400;//set bounds for screen area
         public static final int RADIUS = 15;//set size of balls
            private Color bgColor = java.awt.Color.lightGray;//may be used to clear background of JFrame
         private int x, y;//x & y coordinates
         private int speedX, speedY;//distances to use to redraw the balls
            private Color color = null;//the color of a ball
            Method Name: Ball(int initX, int initY, Color colorin) 
            Return Value: none
            Input Parameters: int, int , color
            Method Description: Constructor that creates a Ball object
         public Ball(int initX, int initY, Color colorin)
              x = initX;
              y = initY;
                    color = colorin;
                 speedX = (int)(1 + (Math.random() * 10));
              speedY = (int)(1 + (Math.random() * 10));
            Method Name: move()
            Return Value: none
            Input Parameters: none
            Method Description: This calculates the balls position and keeps it within
            the 400 pixel size of the application frame.
         public void move()
              x += speedX;
              y += speedY;
              if ((x - RADIUS < 0) || (x + RADIUS > APP_SIZE))
                   speedX = -speedX;
                   x += speedX;
              if ((y - RADIUS < 0) || (y + RADIUS > APP_SIZE))
                   speedY = -speedY;
                   y += speedY;
         } //EOMove
            Method Name: draw(Graphics bg) 
            Return Value: none
            Input Parameters: graphics
            Method Description: This method is how the ball draws itself
            public void draw(Graphics bg)
                bg.setColor( color );
                bg.fillOval(x - RADIUS, y - RADIUS, 2 * RADIUS, 2 * RADIUS);
    //PROBLEM AREA PROBLEM AREA PROBLEM AREA PROBLEM AREA PROBLEM AREA PROBLEM AREA
            Method Name: run() 
            Return Value: none
            Input Parameters: none
            Method Description: This method is called by start() in the Balls.java file
            found in the mousePressed() method. however, it does not work properly.
         public void run()
               while(true)
              try
                 Thread.sleep(100);
                       move();
                       draw(g);
                       repaint();
                    catch(Exception e)
                    e.printStackTrace( System.out );
        }//EOF

    There needs to be only one thread. On every mouse pressed just add a new Ball object to the vector located in Balls class. That thread need only invoke a repaint on your main class called Balls.
    public class Balls extends JFrame implements Runnable,MouseListener{
    Vector vector = new Vector();
    public static void main(String[] args){
    Balls balls = new Balls(); balls.setSize(400,400);
    balls.setVisible(true);
    Thread thread = new Thread(this);
    thread.start();
    public void run(){ 
    while(true){
    repaint();
    try{
    Thread.sleep(4000); //delay
    }catch(InterruptedException e){}
    public void paint(Graphics){
    for(i=0; i<vector.size(); i++){
    Ball b = (Ball)vector.elementAt(i);
    reposition(b);
    g.drawArc(b.getX(),b.getY(),0,360);
    public void reposition(Ball b){
    // reposition ball using balls get/set methods.
    public void MouseClicked(MouseEvent e){
    // add a new ball to vector.
    public class Ball{
    int x,y;
    public int getX(){ return x; }
    public int getY(){ return y; }
    public int setX(int x){ this.x = x; }
    public int setY(int y){ this.y = y; }
    Do check the syntax and compilation errors. The code above should give you some idea for approach.

Maybe you are looking for