Unusual lParam behavior upon creating a thread

Hello,
I need some help passing a struct as a parameter to my thread.
I have a few variables in a structure and what happens is that only 2 specific values change their values upon calling CreateThread(...). I will post the code here to simplify the explanation:
struct ThreadParams {
HINSTANCE hInstance; // duh
HANDLE *hevent; // pointer to an array of 3 event handles
HWND *hwnd; // pointer to an array of 2 valid window handles
And the piece of code where the error occurs:
tParams.hInstance = hInstance; // tParams is a ThreadParams struct
tParams.hwnd = hwnd; // In the main(calling) thread I have a pointer to a 2 dimensional array(to avoid confusion: it points to the first HWND element) and I just copy the address to the pointer inside the struct.
tParams.hevent = hevent;
htrd[0] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)render_thread_proc, (LPVOID)&tParams, 0, NULL);
htrd[1] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)compute_thread_proc, (LPVOID)&tParams, 0, NULL);
So to the problem:
Using the debugger, upon executing this line:
htrd[0] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)render_thread_proc, (LPVOID)&tParams, 0, NULL);
the value of the object(s) pointed to by hwnd change. The address is correct in the child and main thread, it's only their values. And as far as I can tell, nothing else happens, even in the child thread no statement has been executed. But in any case, here
is the beginning of the child thread proc:
ThreadParams p = *(ThreadParams*)tParams;
LARGE_INTEGER currentTime;
LARGE_INTEGER prevDrawTime;
LARGE_INTEGER frequency;
LARGE_INTEGER frameTime;
prevDrawTime.QuadPart = 0;
QueryPerformanceFrequency(&frequency);
frameTime.QuadPart = (frequency.QuadPart * DRAW_TIME) / 1000000;
WaitForMultipleObjects(2, &(p.hevent[1]), TRUE, INFINITE);
I hope someone can help me with this little problem and I thank you in advance.

I can show it if needed, but the declaration of tParams is at the very beginning of the WinMain, so it should be okay, I also tried declaring it as a global variable,  but there was no change.
That's a good point, I am using the same values for both threads, in the end I will probably declare a global variable, but I am intrigued by this problem since tParams does not go out of scope and all the other values are correct and remain the same in
both the child and main thread, it's only the window handles that change.
Here is the complete WinMain and render_thread_proc, keep in mind that there is another thread being created immediately after the render thread, if I comment out the first thread's creation, the second one has the same effect on the window handles.
WinMain
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
ThreadParams tParams;
MSG msg;
bool shouldClose = false;
HANDLE htrd[] = { NULL, NULL }, hevent[] = { NULL, NULL, NULL };
LMB = false, SHIFT = false, constant = complex();
hevent[0] = CreateEvent(NULL, TRUE, FALSE, NULL);
hevent[1] = CreateEvent(NULL, FALSE, FALSE, NULL);
hevent[2] = CreateEvent(NULL, FALSE, FALSE, NULL);
HWND *hwnd = create_windows(hInstance, hevent);
if (hwnd[0] == NULL) {
PostMessage(hwnd[0], WM_ERROR, NULL, 0x1001);
shouldClose = true;
if (hwnd[1] == NULL) {
PostMessage(hwnd[0], WM_ERROR, NULL, 0x1002);
if (shouldClose) return 0x1003;
else shouldClose = true;
if(!shouldClose) {
tParams.hInstance = hInstance;
tParams.hwnd = hwnd;
tParams.hevent = hevent;
htrd[0] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)render_thread_proc, (LPVOID)&tParams, 0, NULL);
htrd[1] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)compute_thread_proc, (LPVOID)&tParams, 0, NULL);
shouldClose = false;
while (!shouldClose)
PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE);
if (msg.message == WM_QUIT) {
shouldClose = true;
else {
TranslateMessage(&msg);
DispatchMessage(&msg);
SetEvent(hevent[0]);
if (msg.wParam == 0x4000) SetEvent(hevent[2]);
WaitForMultipleObjects(2, htrd, TRUE, INFINITE);
DestroyWindow(hwnd[0]);
DestroyWindow(hwnd[1]);
CloseHandle(hevent[0]);
CloseHandle(hevent[1]);
CloseHandle(hevent[2]);
CloseHandle(htrd[0]);
CloseHandle(htrd[1]);
return (int)msg.wParam;
render_thread_proc:
int render_thread_proc(LPVOID tParams) {
ThreadParams p = *(ThreadParams*)tParams;
LARGE_INTEGER currentTime;
LARGE_INTEGER prevDrawTime;
LARGE_INTEGER frequency;
LARGE_INTEGER frameTime;
prevDrawTime.QuadPart = 0;
QueryPerformanceFrequency(&frequency);
frameTime.QuadPart = (frequency.QuadPart * DRAW_TIME) / 1000000;
WaitForMultipleObjects(2, &(p.hevent[1]), TRUE, INFINITE);
if (glContext.create_context(p.hwnd[0], p.hInstance)) {
SendMessage(p.hwnd[0], WM_ERROR, NULL, glContext.error);
return glContext.error;
if (glContext.setup(read_file("tex_vs.glsl"), read_file("tex_fs.glsl"))) {
glContext.destroy(); // Could cause an additional error, look into it.
SendMessage(p.hwnd[0], WM_ERROR, NULL, glContext.error);
return glContext.error;
SetEvent(p.hevent[0]);
WaitForSingleObject(p.hevent[2], INFINITE);
SetEvent(p.hevent[1]);
while (WaitForSingleObject(p.hevent, 0) == WAIT_TIMEOUT) {
QueryPerformanceCounter(&currentTime);
if (currentTime.QuadPart - prevDrawTime.QuadPart > frameTime.QuadPart) {
prevDrawTime.QuadPart = currentTime.QuadPart;
glContext.render_scene();
glContext.destroy();
return 0;

Similar Messages

  • Jdbc driver creates new thread for each statement with a query timeout set

    I am profiling a web application that is using the Microsoft JDBC driver, version 1.1 to connect to a sql server 2005 database. Each java.sql.Statement that is created, within the application, gets a query timeout value set on it ( statement.setQueryTimeout(...) ).
    I have discovered that the JDBC driver creates a new thread to monitor each Statement and the query timeout value. When the application is under load these threads are getting created faster then they are being destroyed and I am concerned that this will cause a performance problem in production.
    One option I have is to remove the query timeout value and the monitor threads will not be created, another is to change JDBC drivers.
    I'm curious is there any way to control this behavior so that these threads are not created or are managed more efficiently.  Is there a workaround that anyone is aware of?   Is this considered a bug?
    I have found a similar bug here for the 2000 driver:
    http://support.microsoft.com/default.aspx/kb/894552
    Cheers

    Hi,
    Thank you for using the Microsoft SQL Server JDBC driver.  You are correct that a new thread is started to monitor the query timeout when a statement is executed.  This is a potential performance issue that we may look at addressing in the upcoming v1.2 release.  The current behavior is not configurable.  The only workaround with the v1.1 driver is to limit your use of query timeouts to only those statements which you reasonably might expect to actually time out.
    We do take customer feedback very seriously, so if anyone else is concerned about this particular issue, please chime in and we will be able to give it appropriate weight.
    --David Olix [MSFT]

  • "Run Script" (F5) Flacky Behavior with CREATE PROCEDURE and PACKAGE

    When I have the following create statement in a SQL Worksheet and run the script using "Run Script" (F5), I get the "PROCEDURE bogus Compiled." message. Why does it not tell me that there was a compile error? The procedure is marked with a little red "X" in the connections pane.
    CREATE OR REPLACE PROCEDURE bogus IS
    BEGIN
      x := 1;
    END;
    /Also, when I have the following command in a SQL Worksheet and run the script using "Run Script" (F5), I get the "PROCEDURE bogus Compiled." message. The difference is that I removed the slash after the CREATE PROCEDURE command. I can go into that procedure in the database via the Connections pane, click on the compile button, and the procedure compiles with no errors. Why does it not compile in a script when missing the slash?
    CREATE OR REPLACE PROCEDURE bogus IS
    BEGIN
      NULL;
    END;I noticed the same flaky behavior with CREATE PACKAGE BODY as well. This is in version 1.0.0.14.67 on Windows XP. Has this been fixed in the latest version?
    Mike

    I found a number of earlier posts on this (going back to at least v804), but I cannot find a thread with a response from the SQL Developer team - see:
    Package compilation error
    Succesful compilation message and Compiling Invalid Objects
    Creating a stored procedure from a file does not show compilation errors
    Re: Syntax Error Feedback
    I assume that it is just a bug with SQL Developer that it does not check for compilation errors when determining the status message to display (ie "PROCEDURE bogus Compiled"). At least now we get the little red cross on the navigator to tell us it is invalid :)

  • 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

Maybe you are looking for