Create a thread

Can the reports created be only in excel sheet or can we create a chart view also?

Hi ,
I'm new to CR fo VS2010, so please bear with me. How do i allow, crystal report to export only PDF files? When i try to export crystal report, it gives me so many options and i only want users to download PDF format. Any help is greatly appreciated.

Similar Messages

  • Is it possible to create a thread and run it in background in nokia ??

    Is it possible to create a thread and run it in background in nokia series 40 mobile phones using j2me ??

    Probably a good question for ForumNokia. If you mean start up a thread and run in the background while your MIDlet UI does other things, then sure, why not. If you mean that you want to exit your MIDlet, but leave a thread running in the background, then I don't believe you can do this on series 40. S60 is another story since it supports multiple tasks.

  • Error logs message " HTTP3090: Failed to create logging thread " ?

    hi, i need your help.
    i have "sjs web6.1sp8" on hp-ux machine
    below message suddenly appear at load testing.
    [Jul/2010:03:01:52] failure ( 6477): HTTP3090: Failed to create logging thread (Insufficient resources)
    [Jul/2010:03:04:53] failure ( 6477): Error creating DaemonSession thread
    what's mean message? how do action?
    thank for rep..
    Edited by: swardseven on Aug 1, 2010 10:38 PM

    First - 6.1sp8 is old. Very old. You should be testing with the latest SP of 6.1 if at all possible.
    Second - According to the error the process is somehow resource constrained. Are you out of RAM? Swap? Is the process out of file descriptors? Some other resource? Check your OS limits and per-process limits and compare them to the Web Server consumption.

  • What is better way for creating a thread? Why?

    A thread can be create in two way, extending Thread class or implimenting Runnable.
    What is better way for creating a thread? Why?

    Implementing Runnable
    See FAQ #1 here [http://forum.java.sun.com/ann.jspa?annID=9]

  • Memory leak when creating new thread.

    Hi,
    Each time i create a thread, it causes 8 bytes memory leak. The testing code is as below and you can see mem usage increasing in Windows Task Manager. But if i don't call ::OCIEnvCreate(), no memory leak.
    Memory validator shows the following call stack information:
    ........largest allocation 8 bytes at .......
    =>OraOCIEI10.dll ss_mem_thread_attach
    =>OraOCIEI10.dll sscoresetserverflag
    =>OraOCIEI10.dll slzgetevar
    =>ntdll.dll LdrInitializeThunk
    Anyone knows what is goiing on?
    /Yue
    #include <stdio.h>
    #include <windows.h>
    #include <process.h>
    #include <oci.h>
    static OCIEnv *env;
    static unsigned int counter = 0;
    unsigned __stdcall ThreadFunc(void* pArg)
    counter++;
    printf( "In %uth thread...\n", counter );
    Sleep(100);
    _endthreadex( 0 );
    return 0;
    int main( int argc, const char* argv[] )
         sword rc = ::OCIEnvCreate(&env, OCI_DEFAULT, NULL, NULL, NULL, NULL, 0, NULL );
         for(;;)
              HANDLE hThread;
              unsigned threadID;
              // Create the second thread.
              hThread = (HANDLE)_beginthreadex( NULL, 0, &ThreadFunc, NULL, 0, &threadID );
              WaitForSingleObject( hThread, INFINITE );
              // Destroy the thread object.
              CloseHandle( hThread );
         return 0;
    }

    Hi,
    I'm not suprised.
    OCI offers the feature OCIThreadKey that allow you to store a pointer within a thread context (without using OCIThread, just using natives threads).
    So OCI needs to catch thread creation to be able to register storage for its OCIThread key value and be able, once the thread is finished to call a callback with the pointer value associated with the thread....

  • Unable to create native thread in Normal Condition

    I am trying to analyze the "OOM unable to create native thread" error that occurred in our application. I wrote a sample program which has to creates 5000 threads and monitored it using JConsole.
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    * ThreadJvmMemory.java
    * Created on June 1, 2007, 9:49 AM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    * @author Administrator
    public class ThreadJvmMemory extends Thread{
    /** Creates a new instance of ThreadJvmMemory */
    BufferedReader in = null;
    public ThreadJvmMemory() {
    public static void main(String args[]){
    ThreadJvmMemory dummy = new ThreadJvmMemory();
    dummy.waitTillEnter();
    for(int i=0;i<5000;i++){
    if(i%1000==0){
    System.out.println(i);
    dummy.waitTillEnter();
    ThreadJvmMemory dummy1 = new ThreadJvmMemory();
    dummy1.start();
    public void run(){
    //System.out.println("Here");
    Object dummyObject = new Object();
    try {
    in = new BufferedReader(new InputStreamReader(System.in));
    in.readLine();
    } catch (IOException ex) {
    ex.printStackTrace();
    System.out.println("Came out of the thread");
    public void waitTillEnter(){
    try {
    if(in==null)
    in = new BufferedReader(new InputStreamReader(System.in));
    in.readLine();
    } catch (IOException ex) {
    ex.printStackTrace();
    I started the program using the following command line option..
    "c:\Program Files\Java\jdk1.5.0_09\bin\java.exe" -Dcom.sun.management.jmxremote.port=9979 -Xmx512m -Xminf0.1 -Xmaxf0.1 -XX:MaxPermSize=256m -XX:PermSize=256m -XX:+<GCTYPE> -XX:+PrintGCDetails
    where GCType will be UseTrainGC or UseSerialGC or UseParallelGC or
    What i observe in all the cases, there are no more than 1000 threads getting created . After completion of 1000 threads garbage collector keeps running and no more threads get created. Since i have configured heapsize to be 512m, PermGenSpace to be 256 and default value for process sapece is 2gb, JVM would be able to create only 1000 threads as per the formula "NoOfThreads = Process space - (Heap + permGen+some for VM initialization)/Stack Size" (correct me if i am wrong). But why i am not getting OutOfMemoryError while creating native thread. Moreover i can observer non-heap (Perm Gen) space keep growing overtime. But there is enough space in all other spaces.So my doubts are
    1. Actually when we will get OOM error saying unable to create Native thread. To be more specific when which space occupied i will get this error.
    2. Is there any way to configure process space. IMO No ?? Confirm ??
    3. Does any one tried using a a tool that analyzes verboseGC output of SUN JVM. If so can you give any pointer. I have read through GCPortal, but i havent fully deployed it.
    Java version is 1.5.0
    OS Windows 2k3
    Snippet of GC Output
    [GC [DefNew: 5208K->38K(5824K), 0.0072564 secs] 32049K->26879K(34636K), 0.0080451 secs]
    [GC [DefNew: 5222K->24K(5824K), 0.0070320 secs] 32063K->26868K(34636K), 0.0078097 secs]
    [GC [DefNew: 5208K->39K(5824K), 0.0082161 secs] 32052K->26883K(34636K), 0.0090173 secs]
    [GC [DefNew: 5223K->27K(5824K), 0.0080766 secs] 32067K->26874K(34636K), 0.0089273 secs]
    [GC [DefNew: 5211K->39K(5824K), 0.0071186 secs] 32058K->26886K(34636K), 0.0078970 secs]
    [GC [DefNew: 5223K->25K(5824K), 0.0070952 secs] 32070K->26875K(34636K), 0.0078766 secs]
    [GC [DefNew: 5209K->21K(5824K), 0.0069871 secs] 32059K->26872K(34636K), 0.0077657 secs]

    I am trying to analyze the "OOM unable to create native thread" error that occurred in our application. I wrote a sample program which has to creates 5000 threads and monitored it using JConsole.
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    * ThreadJvmMemory.java
    * Created on June 1, 2007, 9:49 AM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    * @author Administrator
    public class ThreadJvmMemory extends Thread{
    /** Creates a new instance of ThreadJvmMemory */
    BufferedReader in = null;
    public ThreadJvmMemory() {
    public static void main(String args[]){
    ThreadJvmMemory dummy = new ThreadJvmMemory();
    dummy.waitTillEnter();
    for(int i=0;i<5000;i++){
    if(i%1000==0){
    System.out.println(i);
    dummy.waitTillEnter();
    ThreadJvmMemory dummy1 = new ThreadJvmMemory();
    dummy1.start();
    public void run(){
    //System.out.println("Here");
    Object dummyObject = new Object();
    try {
    in = new BufferedReader(new InputStreamReader(System.in));
    in.readLine();
    } catch (IOException ex) {
    ex.printStackTrace();
    System.out.println("Came out of the thread");
    public void waitTillEnter(){
    try {
    if(in==null)
    in = new BufferedReader(new InputStreamReader(System.in));
    in.readLine();
    } catch (IOException ex) {
    ex.printStackTrace();
    I started the program using the following command line option..
    "c:\Program Files\Java\jdk1.5.0_09\bin\java.exe" -Dcom.sun.management.jmxremote.port=9979 -Xmx512m -Xminf0.1 -Xmaxf0.1 -XX:MaxPermSize=256m -XX:PermSize=256m -XX:+<GCTYPE> -XX:+PrintGCDetails
    where GCType will be UseTrainGC or UseSerialGC or UseParallelGC or
    What i observe in all the cases, there are no more than 1000 threads getting created . After completion of 1000 threads garbage collector keeps running and no more threads get created. Since i have configured heapsize to be 512m, PermGenSpace to be 256 and default value for process sapece is 2gb, JVM would be able to create only 1000 threads as per the formula "NoOfThreads = Process space - (Heap + permGen+some for VM initialization)/Stack Size" (correct me if i am wrong). But why i am not getting OutOfMemoryError while creating native thread. Moreover i can observer non-heap (Perm Gen) space keep growing overtime. But there is enough space in all other spaces.So my doubts are
    1. Actually when we will get OOM error saying unable to create Native thread. To be more specific when which space occupied i will get this error.
    2. Is there any way to configure process space. IMO No ?? Confirm ??
    3. Does any one tried using a a tool that analyzes verboseGC output of SUN JVM. If so can you give any pointer. I have read through GCPortal, but i havent fully deployed it.
    Java version is 1.5.0
    OS Windows 2k3
    Snippet of GC Output
    [GC [DefNew: 5208K->38K(5824K), 0.0072564 secs] 32049K->26879K(34636K), 0.0080451 secs]
    [GC [DefNew: 5222K->24K(5824K), 0.0070320 secs] 32063K->26868K(34636K), 0.0078097 secs]
    [GC [DefNew: 5208K->39K(5824K), 0.0082161 secs] 32052K->26883K(34636K), 0.0090173 secs]
    [GC [DefNew: 5223K->27K(5824K), 0.0080766 secs] 32067K->26874K(34636K), 0.0089273 secs]
    [GC [DefNew: 5211K->39K(5824K), 0.0071186 secs] 32058K->26886K(34636K), 0.0078970 secs]
    [GC [DefNew: 5223K->25K(5824K), 0.0070952 secs] 32070K->26875K(34636K), 0.0078766 secs]
    [GC [DefNew: 5209K->21K(5824K), 0.0069871 secs] 32059K->26872K(34636K), 0.0077657 secs]

  • Creating TestStand threads from a DLL

    I have a DLL function that creates a thread to maintain a LabWindows/CVI user-interface. I'm interested in having UI events trigger the execution of a sequence in TestStand.
    In the TestStand API, I can find methods to start a whole new Execution. But I was really hoping to create a TestStand thread within the original Execution. I can't find a way to do that. Is it possible?
    I'm using TestStand 2.0, by the way.

    The only way to start a thread within an execution is with a sequence call step.
    To accomplish what you describe, your sequence could start a thread that waits for requests to start new threads (requests sent via any convenient mechanism such as TestStand events or queues, Windows synchronization primitives, TestStand or DLL variables, etc.). When the thread receives a request, it would use a sequence call step to launch the appropriate new thread.

  • Failure: Error creating DaemonSession thread

    Hi All,
    I am getting failure: Error creating DaemonSession thread errior when I start the web-server instance as follows
    bash-3.00$ ./start
    Sun ONE Web Server 6.1SP2 B04/07/2004 17:28
    info: CORE5076: Using [Java HotSpot(TM) Server VM, Version 1.4.1.05] from [Hewle
    tt-Packard Company]
    info: WEB0100: Loading web module in virtual server [https-myWebServer] at [/sea
    rch]
    info: HTTP3072: [LS ls1] http://hpux-lab:8000 ready to accept requests
    failure: Error creating DaemonSession thread
    startup: server started successfully
    bash-3.00$
    Please reply with a solution

    This was related to kernel level settings
    The attribute max_thread_proc was set to 64 which was not enough. So increase that to 2048 and the Web-Server Instance wil start.

  • Error creating DaemonSession thread

    Hi All,
    I am having the "JVMCI015:OutOfMemoryError" with my Sun ONE Web Server 6.1 SP1 on IBM AIX platform. I am using IBM JDK 1.4.1.
    I always hit this error when trying to load test the web server with 1500 concurrent users. I have set yhr RqThrottle tp 1536 and the MaxKeepAliveConnections is 1024. Java Heap Size is 512m. I even tried increase the heap size to 1.5 G, but the error still occur.
    Would appreciate if any solution is given.
    The detailed error is :
    [28/May/2004:17:04:09] info (28120): CORE3274: successful server startup
    [28/May/2004:17:05:50] failure (28120): Error creating DaemonSession thread
    [28/May/2004:17:05:50] failure (28120): Error creating DaemonSession thread
    [28/May/2004:17:05:50] failure (28120): Error creating DaemonSession thread
    [28/May/2004:17:05:50] failure (28120): Error creating DaemonSession thread
    [28/May/2004:17:05:50] failure (28120): Error creating DaemonSession thread
    [28/May/2004:17:05:50] failure (28120): Error creating DaemonSession thread
    [28/May/2004:17:05:50] failure (28120): Error creating DaemonSession thread
    [28/May/2004:17:05:50] failure (28120): Error creating DaemonSession thread
    [28/May/2004:17:05:50] failure (28120): Error creating DaemonSession thread
    [28/May/2004:17:05:50] failure (28120): Error creating DaemonSession thread
    [28/May/2004:17:05:50] failure (28120) https-uob: for host 10.128.1.33 trying to POST /servlet/LiveGiverServlet, service-j2ee
    reports: StandardWrapperValve[LiveGiverServlet]: WEB2792: Servlet.service() for servlet LiveGiverServlet threw exception
    javax.servlet.ServletException: WEB2664: Servlet execution threw an exception
    at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:793)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java(Compiled Code))
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java(Compiled Code))
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java(Compiled Code))
    at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
    at com.iplanet.ias.web.WebContainer.service(WebContainer.java:586)
    ----- Root Cause -----
    java.lang.OutOfMemoryError: JVMCI015:OutOfMemoryError, cannot create anymore threads due to memory or resource constraints
    at java.lang.Thread.start(Native Method)
    at com._3rdfrontier.livegiver.servers.pushchannel.LiveGiverClientConsumer.<init>(LiveGiverClientConsumer.java(Compiled
    Code))
    at com._3rdfrontier.livegiver.servers.pushchannel.LiveGiverAggregator.subscribe(LiveGiverAggregator.java(Compiled Code
    at com._3rdfrontier.livegiver.servers.pushchannel.LiveGiverAggregator.handleRequest(LiveGiverAggregator.java:838)
    at LiveGiverServlet.doPost(LiveGiverServlet.java:1094)
    at LiveGiverServlet.service(LiveGiverServlet.java:437)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
    at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java(Compiled Code))
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java(Compiled Code))
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java(Compiled Code))
    at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
    at com.iplanet.ias.web.WebContainer.service(WebContainer.java:586)
    magnus.conf
    # The NetsiteRoot, ServerName, and ServerID directives are DEPRECATED.
    # They will not be supported in future releases of the Web Server.
    NetsiteRoot /package/SUNWwbsvr
    ServerName AIX1
    ServerID https-test
    RqThrottle 1536
    DNS off
    Security off
    PidLog /package/SUNWwbsvr/https-test/logs/pid
    User qgdev
    #StackSize 131072
    StackSize 524288
    TempDir /tmp/https-test-5328a767
    PostThreadsEarly on
    KernelThreads off
    #enabling statistic
    UseNativePoll off
    KeepAliveThreads 2
    MaxKeepAliveConnections 1024
    AsyncDNS off
    Init fn=flex-init access="$accesslog" format.access="%Ses->client.ip% - %Req->vars.auth-user% [%SYSDATE%] \"%Req->reqpb.clf-request%\" %Req->srvhdrs.clf-status% %Req->srvhdrs.content-length%"
    Init fn="load-modules" shlib="/package/SUNWwbsvr/bin/https/lib/libj2eeplugin.so" shlib_flags="(global|now)"
    Init fn="stats-init" update-interval="5" virtual-servers="1" profiling="yes"
    server.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!--
    Copyright (c) 2003 Sun Microsystems, Inc. All rights reserved.
    Use is subject to license terms.
    -->
    <!DOCTYPE SERVER PUBLIC "-//Sun Microsystems Inc.//DTD Sun ONE Web Server 6.1//EN" "file:///package/SUNWwbsvr/bin/https/dtds/sun-web-server_6_1.dtd">
    <SERVER qosactive="false">
    <PROPERTY name="docroot" value="/package/SUNWwbsvr/docs"/>
    <PROPERTY name="accesslog" value="/package/SUNWwbsvr/https-test/logs/access"/>
    <PROPERTY name="user" value=""/>
    <PROPERTY name="group" value=""/>
    <PROPERTY name="chroot" value=""/>
    <PROPERTY name="dir" value=""/>
    <PROPERTY name="nice" value=""/>
    <LS id="ls1" port="5050" servername="AIX1" defaultvs="https-test" ip="any" security="off" acceptorthreads="4" blocking="false"/>
    <MIME id="mime1" file="mime.types"/>
    <ACLFILE id="acl1" file="/package/SUNWwbsvr/httpacl/generated.https-test.acl"/>
    <VSCLASS id="vsclass1" objectfile="obj.conf" rootobject="default" acceptlanguage="false">
    <VS id="https-test" connections="ls1" mime="mime1" aclids="acl1" urlhosts="AIX1" state="on">
    <USERDB id="default"/>
    <WEBAPP uri="/" path="/projects/test/web/http" enabled="true"/>
    </VS>
    </VSCLASS>
    <JAVA javahome="/package/SUNWwbsvr/bin/https/jdk" serverclasspath="" classpathsuffix="" envclasspathignored="true" nativelibrarypathprefix="" debug="off" debugoptions="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n" dynamicreloadinterval="-1">
    <JVMOPTIONS>-Djava.security.auth.login.config=/package/SUNWwbsvr/https-test/config/login.conf</JVMOPTIONS>
    <JVMOPTIONS>-Djava.util.logging.manager=com.iplanet.ias.server.logging.ServerLogManager</JVMOPTIONS>
    <JVMOPTIONS>-Dorg.omg.CORBA.ORBClass=com.ibm.CORBA.iiop.ORB</JVMOPTIONS>
    <JVMOPTIONS>-Dorg.omg.CORBA.ORBSingletonClass=com.ibm.rmi.corba.ORBSingleton</JVMOPTIONS>
    <JVMOPTIONS>-Djavax.rmi.CORBA.UtilClass=com.ibm.CORBA.iiop.UtilDelegateImpl</JVMOPTIONS>
    <JVMOPTIONS>-Djavax.rmi.CORBA.StubClass=com.ibm.rmi.javax.rmi.CORBA.StubDelegateImpl</JVMOPTIONS>
    <JVMOPTIONS>-Djavax.rmi.CORBA.PortableRemoteObjectClass=com.ibm.rmi.javax.rmi.PortableRemoteObject</JVMOPTIONS>
    <JVMOPTIONS>-Xms512m</JVMOPTIONS>
    <JVMOPTIONS>-Xmx512m</JVMOPTIONS>
    <SECURITY defaultrealm="file" anonymousrole="ANYONE" audit="false">
    <AUTHREALM name="file" classname="com.iplanet.ias.security.auth.realm.file.FileRealm">
    <PROPERTY name="file" value="/package/SUNWwbsvr/https-test/config/keyfile"/>
    <PROPERTY name="jaas-context" value="fileRealm"/>
    </AUTHREALM>
    <AUTHREALM name="native" classname="com.iplanet.ias.security.auth.realm.webcore.NativeRealm">
    <PROPERTY name="jaas-context" value="nativeRealm"/>
    </AUTHREALM>
    <AUTHREALM name="ldap" classname="com.iplanet.ias.security.auth.realm.ldap.LDAPRealm">
    <PROPERTY name="directory" value="ldap://localhost:389"/>
    <PROPERTY name="base-dn" value="o=isp"/>
    <PROPERTY name="jaas-context" value="ldapRealm"/>
    </AUTHREALM>
    </SECURITY>
    <RESOURCES/>
    </JAVA>
    <LOG file="/package/SUNWwbsvr/https-test/logs/errors" loglevel="info" logvsid="true" logstdout="false" logstderr="true" logtoconsole="false" createconsole="false" usesyslog="false"/>
    </SERVER>

    Hi Elving,
    I agree with you that we don't need so many threads to support concurrent many users for normal web application.
    But what happen is that if i have an application which will take a very long time to process a request and probably will not complete the request for a few hours. So if i want to test for 1500 concurrent users, i need to have at least 1500 threads to service this kind of request. Otherwise, some of the users may need to wait for a few hours in order to get serviced by web server.
    Thus, is there a way to allow OS or web server to create this many of threads?

  • Creating a Thread so that I don't wait on a Method?

    Good Evening All!
    I have a simple java program that reads a file containing XML and then posts that XML to a webserver. When I run the program I would normally have about 5,000 xml "documents" in the file that need to be posted to the webserver. Today, I have create a method to read from the file and then a method to post the data and that is contained in a do loop. The issue that I have is that it takes sever seconds for the webserver to respond to each request. Thus it takes about 5 seconds for each call to post. (The Post method that I have created does not return any data. It does connect to a logging database and logs the result that it received. )
    Instead of waiting for the call to Post to come back, could I create a thread and then run post inside of its own thread so that I can read the next line in the file and post it before the first finishes?
    Thanks,
    Doug

    Thanks Again Paul.
    If I can ask one more...How do you pass a recordSet to run? I may have over stated how simple my program is. The code is below. It is reading an exce file and then passing two of the cell values to my post method.
    I have tried a couple of things, but so far no matter what I do I can't put the rs.getString() calls in run without the Microsoft driver producing errors.
    So, in this case do you have any advice?
    Thanks,
    Doug
    public static void main(String[] args)
    Connection c = null;
    Statement stmnt = null;
    try
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    c = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=" + args[0]);
    stmnt = c.createStatement();
    String query = "Select * from [data$]" ;
    ResultSet rs = stmnt.executeQuery( query );
    while( rs.next() )
    XML.Post( rs.getString(1) + rs.getString(2) );
    catch( Exception e )
    System.err.println( e );
    }

  • Creating multiple Threads in applets

    Hi, I need some help creating multiple threads in applets. If you look at the simple code example below you�ll see that it uses one thread that calls the findTarg() method that gives its sleep() a value and makes the oval find its new target.
    What I want to know is how do I create a new thread in this applet? � So for example I could call a findTarg2() method from within a new thread that sets its sleep() to a faster or slower value and starts at the same time as findTarg().
    Hope that makes sense.
    <applet code="thread.class" height=400 width=400>
    </applet>
    import java.awt.Graphics;
    import java.awt.*;
    import java.awt.event.*;
    public class thread extends java.applet.Applet implements Runnable {
    int x = 200;
    int y = 200;
    int xTarg;
    int yTarg;
    int sleeper;
    boolean go;
    Thread first;
    public void start(){
    if(first == null); {
    first = new Thread(this);
    first.start();
    public void run(){
    while (first != null) {
    findTarg();
    try {
    Thread.sleep(sleeper);
    } catch (InterruptedException e) { }
    public void findTarg(){    
    if(go == true){
    sleeper = 10;
    if(x < xTarg)x++;
    if(x > xTarg)x--;
    if(y < yTarg)y++;
    if(y > yTarg)y--;
    repaint();
    if((x == xTarg)&&(y == yTarg))go = false;
    public boolean mouseDown(Event evt, int x, int y) {
    xTarg= x;
    yTarg= y;
    go = true;
    return true;
    public void paint(Graphics g) {
    g.setColor(Color.black);
    g.fillOval(x,y,20,20);
    }

    I've found another example and this time it extends JApplet. I'm sorry I can't help you more, but I'm new as well.
    // Fig. 15.7: RandomCharacters.java
    // Demonstrating the Runnableinterface
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class RandomCharacters extends JApplet
    implements Runnable,
    ActionListener {
    private String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    private JLabel outputs[];
    private JCheckBox checkboxes[];
    private final static int SIZE = 3;
    private Thread threads[];
    private boolean suspended[];
    public void init()
    outputs = new JLabel[ SIZE ];
    checkboxes = new JCheckBox[ SIZE ];
    threads = new Thread[ SIZE ];
    suspended = new boolean[ SIZE ];
    Container c = getContentPane();
    c.setLayout( new GridLayout( SIZE, 2, 5, 5 ) );
    for ( int i = 0; i < SIZE; i++ ) {
    outputs[ i ] = new JLabel();
    outputs[ i ].setBackground( Color.green );
    outputs[ i ].setOpaque( true );
    c.add( outputs[ i ] );
    checkboxes[ i ] = new JCheckBox( "Suspended" );
    checkboxes[ i ].addActionListener( this );
    c.add( checkboxes[ i ] );
    public void start()
    // create threads and start every time start is called
    for ( int i = 0; i < threads.length; i++ ) {
    threads[ i ] =
    new Thread( this, "Thread " + (i + 1) );
    threads[ i ].start();
    public void run()
    Thread currentThread = Thread.currentThread();
    int index = getIndex( currentThread );
    char displayChar;
    while ( threads[ index ] == currentThread ) {
    // sleep from 0 to 1 second
    try {
    Thread.sleep( (int) ( Math.random() * 1000 ) );
    synchronized( this ) {
    while ( suspended[ index ] &&
    threads[ index ] == currentThread )
    wait();
    catch ( InterruptedException e ) {
    System.err.println( "sleep interrupted" );
    displayChar = alphabet.charAt(
    (int) ( Math.random() * 26 ) );
    outputs[ index ].setText( currentThread.getName() +
    ": " + displayChar );
    System.err.println(
    currentThread.getName() + " terminating" );
    private int getIndex( Thread current )
    for ( int i = 0; i < threads.length; i++ )
    if ( current == threads[ i ] )
    return i;
    return -1;
    public synchronized void stop()
    // stop threads every time stop is called
    // as the user browses another Web page
    for ( int i = 0; i < threads.length; i++ )
    threads[ i ] = null;
    notifyAll();
    public synchronized void actionPerformed( ActionEvent e )
    for ( int i = 0; i < checkboxes.length; i++ ) {
    if ( e.getSource() == checkboxes[ i ] ) {
    suspended[ i ] = !suspended[ i ];
    outputs[ i ].setBackground(
    !suspended[ i ] ? Color.green : Color.red );
    if ( !suspended[ i ] )
    notify();
    return;
    }

  • Creating a thread

    Hi everyone
    I have a sequence where I have to send a message every 5 seconds or my part will go to sleep. Well while I need to do that I also need to send other messages to the part. So I was thinking of creating a thread that will run in the background sending the required message every 5 seconds and then the main sequence will just run normal. I have never done this in TestStand so I'm asking for any kind of help on creating threads.

    Hi, yaz,
    You may create a multithreaded sequence call. All you need to do is to select "use new thread" under execution option in the step settings for the sequence call.
    Song
    Regards,
    Song Du
    Systems Software
    National Instruments R&D
    Attachments:
    thread.JPG ‏164 KB

  • How to create a Thread Pool

    Freinds,
    I need to create a thread pool for one of my application.My knowledge of threads is limited to beginner level. I am just looking out for some pointers that will help me to create thread pool by reading and understanding any of the availble examples.Please send and if possible explain a bit. I really appreciate the fast response from the crowd. Thanks a lot for the help.

    Hi,
    A thread pool is used in situations where you have multiple requests to be serviced and limited resources. A typical example is a server with multiple clients. The server resources are limited and you cant typically create a thread for each client. You would then pick up one of the vacant threads and process the client and put the thread back in the pool. If you dont have any free threads, then you will make the client wait till you have one.
    The typical questions you need to ask are, pool size, the kind of waiting scheme (queue, stack, prioritized queue, etc.). Additionally if you need a resizable thread pool you would need to define how the pool should shrink (abort operation and terminate or wait for operation to continue and terminate) and things like this.
    If you need a typical implementation of a thread pool, you can go to JavaGuru.com where you have a standard implementation with all relevant details explained.
    Prashanth

  • T o create' n' threads

    Hi I am trying to write a program to create n threads
    I wrote the following code.... i am getting an exception
    Exception in thread "main" java.lang.NullPointerException
    In fact i am in doubt that whether this is the way to create 'n' threads
    Can any one pls tell me how to proceed
    class User extends Thread {
        @Override
        public void run() {
            for (int i = 0; i < 200; i++) {
                System.out.println(Thread.currentThread().getName());
    public class ThreadCLASS {
        public static void main(String[] args) {
            // TODO code application logic here
            User[] t = null;
            int n = 2;
            for (int j = 0; j < n; j++) {
                t[j] = new User();
                t[j].start();
    }

    today i found a way to get free money online, it is by the paypal accounts and the way is like this:
    1-open this link http://www.AWSurveys.com/HomeMain.cfm?RefID=ettietti
    2- sign up to a new account
    3-write comments about the surveys until u get them all in total 27$
    4-start sending emails or put your link in a forum as i did to freinds and people and get 1.25$ on and single person
    Till now i got 82$ you can get up to 500$ and FREE so dont lose the chance and sign up now

  • What is the impact of creating a thread in a class or outside of the class

    Hi Java Experts;
    I have 2 code examples on how to create new threads.
    The first example instantiates, Starts and Joins the Threads Externally.
    The second example Starts and Joins the New Thread Internally.
    QUESTIONS:
    1. Is it true that creating the thread internally creates 2 new threads instead of just one. Because the instance of Class A is a thread. And when it starts itself that's another thread.
    2. Am I correct when I say that the another difference between the two is that in the external one, Class B has to wait before creating new instances since the join method is in its loop. But the advantage of Internally created is that Class B can create can create 100 new threads without having to wait on the join.
    are these correct - and is there any other implication of using one versus another.
    Scenario 1: Start and Join the New Thread Externally
    class A implements Runnable{
      public void run(){
      public A(){}
    public String getMiscProperties(){
       //This Methods must be called Only After this thread returns from the run method
    // this is the calling class
    class B implements Runnable{
      public void run(){
         while(true){
         A p2 = new A();
         Thread t2 = new Thread(p2);
         t2.setDaemon(true);
         t2.start();
         try{
              t2.join();
         }catch(InterruptedException ie){  }
            System.out.println(p2.getMiscProperties());
      public B(){}
    }Scenario 2: Start and Join the New Thread Internally
    class A implements Runnable{
      public void run(){
      public A(){
         Thread t2 = new Thread(this);
         t2.setDaemon(true);
         t2.start();
         try{
              t2.join();
         }catch(InterruptedException ie){  }
      public String getMiscProperties(){
       //This Methods must be called Only After this thread returns from the run method
    // this is the calling class
    class B implements Runnable{
      public void run(){
         while(true){
         A p2 = new A();
            System.out.println(p2.getMiscProperties());
      public B(){}

    Hi,
    1. A thread is created only after you do a
    new Thread(..); // (or its subclass)It does not matter whether you do that internally or externally. You do not get a new thread from constructing a class that implements Runnable if this class is not a Thread (or its subclass).
    In particular, the line:
    A p2 = new A();does not create a new thread by itself. You can verify this by putting
    System.out.println(Thread.currentThread().getName());before that line and in the class 'A' constructor.
    2. No. Your internally created thread will complete first because it is joined before B.run() gets a chance to create another thread.
    If you want to start new threads before other threads complete, you have to do so before the join() method, or you can eliminate join() completely. When you call T.join(), that thread waits for thread T to complete before carrying on.

  • Failed to Create Logging Thread

    I'm getting an error in my iplanet 6.0 error log that reads
    failure ( 7951): Failed to create logging thread (Insufficient
    resources)
    This is on an HP-UX 11.0 system
    I'm not sure what parameter I need to increase. Is it a Kernal param on
    the HP system or is it a param within the iplanet webserver.
    Has anyone seen this or know how to resolve???

    Did you ever get a response or figure this out. I getting the same problem. I think it is a resource issue on my server

Maybe you are looking for