-
1. Re: Thread of Control IDs
kapitanpetko Aug 12, 2010 9:28 PM (in response to j1.jonathan.m.clarke.dsl.pipex.com)Nothing to do with Seam, but:
- if you are using log4j, use the %t conversion pattern to output the executing thread's name in the logs
- use Thread.currentThread().getId/Name()
As usual, browsing the API reference helps.
-
2. Re: Thread of Control IDs
j1.jonathan.m.clarke.dsl.pipex.com Aug 13, 2010 5:33 AM (in response to j1.jonathan.m.clarke.dsl.pipex.com)Hi Nikolay,
Thanks for the help. I refrained from even going near the native Java Thread code, because I understood that J2EE (I'm still learning about J2EE and Seam!) and Java Threads are not necessarily happy (or stable) bed-fellows. So, I put your line of code in, yes, I did get some good results, but there is still one outstanding issue. I have one main Quartz job (let's call is JobA) which drives the entire server-side operations of my .ear. The code called in JobA can then spawn other jobs to do certain tasks. However, JobA is only ever spawned once, and runs indefinitely. However, it's ThreadId keeps changing. Is this because Quartz spawns a new thread internally, for each execution cycle?
Jonathan.
-
3. Re: Thread of Control IDs
kapitanpetko Aug 15, 2010 9:50 PM (in response to j1.jonathan.m.clarke.dsl.pipex.com)
Jonathan Clarke wrote on Aug 13, 2010 05:33:
Thanks for the help. I refrained from even going near the native Java Thread code, because I understood that J2EE (I'm still learning about J2EE and Seam!) and Java Threads are not necessarily happy (or stable) bed-fellows.Well, Quartz spawns a bunch of threads right in your JEE app, so you could argue that it's not-compliant :) In any case, IIRC, the spec only says something to the tune of 'don't start your own threads', so as long as you are only checking thread IDs, etc., you should be OK.
So, I put your line of code in, yes, I did get some good results, but there is still one outstanding issue. I have one main Quartz job (let's call is JobA) which drives the entire server-side operations of my .ear. The code called in JobA can then spawn other jobs to do certain tasks. However, JobA is only ever spawned once, and runs indefinitely. However, it's ThreadId keeps changing. Is this because Quartz spawns a new thread internally, for each execution cycle?What do you mean by 'runs indefinitely'? Runs every n minutes? If so, yes the actual thread that executes the job changes, so the thread ID/name will change for every execution. Quartz keeps a thread pool, so if you monitor the log long enough, you should notice that the thread name repeats. Should be something like 'YourSchedulerName-Worker-1/2/3...'.
HTH