Re: [Fwd: Threads in a plug-in]

2009-10-29 Thread Brian Fox
Maven just exits when it's done and then the jdk pulls everything
down. Isn't there a flag you can set on a thread to mark it as a
daemon thread, and then the system waits before killing it?

On Wed, Oct 28, 2009 at 9:20 AM, Gajo Csaba csaba.g...@cosylab.com wrote:
 Good idea! I was actually hoping there was some switch I can set in Maven to
 tell it not to terminate my thread, but I guess your idea would work fine as
 well. Thanks!
 Csaba


 Stephen Connolly wrote:

 add a second goal

 the first goal will store some thread completion object in MavenSession or
 in a Class level static field

 When all threads are finished the completion object will be updated by the
 last thread

 The second goal blocks until the completion object is completed.

 Then add the second goal execution to your project at the appropriate
 phase
 where you need the execution to have completed...

 for example if you start the threads in the process-sources phase, you
 might
 be happy to let them run in the background until the test phase has
 completed, but they must be finished by the time the package phase runs,
 so
 I would bind your execution of the second goal to the test phase

 -Stephen

 2009/10/28 Gajo Csaba csaba.g...@cosylab.com



 -
 To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
 For additional commands, e-mail: users-h...@maven.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: [Fwd: Threads in a plug-in]

2009-10-29 Thread James Russo

Hello,

Actually it is the other way around. Daemon threads will not hold up JVM 
from exiting, but non-deamon threads will.


Marks this thread as either a daemon thread or a user thread. The Java 
Virtual Machine exits when the only threads running are all daemon threads.


The daemon flag will be set if the creating thread is a daemon thread. 
Maybe force the setDaemon to false on the newly created thread and that 
may give you desired effect.


-jr

Brian Fox wrote:

Maven just exits when it's done and then the jdk pulls everything
down. Isn't there a flag you can set on a thread to mark it as a
daemon thread, and then the system waits before killing it?

On Wed, Oct 28, 2009 at 9:20 AM, Gajo Csaba csaba.g...@cosylab.com wrote:
  

Good idea! I was actually hoping there was some switch I can set in Maven to
tell it not to terminate my thread, but I guess your idea would work fine as
well. Thanks!
Csaba


Stephen Connolly wrote:


add a second goal

the first goal will store some thread completion object in MavenSession or
in a Class level static field

When all threads are finished the completion object will be updated by the
last thread

The second goal blocks until the completion object is completed.

Then add the second goal execution to your project at the appropriate
phase
where you need the execution to have completed...

for example if you start the threads in the process-sources phase, you
might
be happy to let them run in the background until the test phase has
completed, but they must be finished by the time the package phase runs,
so
I would bind your execution of the second goal to the test phase

-Stephen

2009/10/28 Gajo Csaba csaba.g...@cosylab.com


  

-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

  


-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: [Fwd: Threads in a plug-in]

2009-10-29 Thread Nick Stolwijk
I think Maven executes a System.exit at the end, which will terminate all
threads, regardless of daemon state.

With regards,

Nick Stolwijk
~Java Developer~

IPROFS BV.
Claus Sluterweg 125
2012 WS Haarlem
http://www.iprofs.nl


On Thu, Oct 29, 2009 at 1:09 PM, James Russo j...@halo3.net wrote:

 Hello,

 Actually it is the other way around. Daemon threads will not hold up JVM
 from exiting, but non-deamon threads will.

 Marks this thread as either a daemon thread or a user thread. The Java
 Virtual Machine exits when the only threads running are all daemon threads.

 The daemon flag will be set if the creating thread is a daemon thread.
 Maybe force the setDaemon to false on the newly created thread and that may
 give you desired effect.

 -jr


 Brian Fox wrote:

 Maven just exits when it's done and then the jdk pulls everything
 down. Isn't there a flag you can set on a thread to mark it as a
 daemon thread, and then the system waits before killing it?

 On Wed, Oct 28, 2009 at 9:20 AM, Gajo Csaba csaba.g...@cosylab.com
 wrote:


 Good idea! I was actually hoping there was some switch I can set in Maven
 to
 tell it not to terminate my thread, but I guess your idea would work fine
 as
 well. Thanks!
 Csaba


 Stephen Connolly wrote:


 add a second goal

 the first goal will store some thread completion object in MavenSession
 or
 in a Class level static field

 When all threads are finished the completion object will be updated by
 the
 last thread

 The second goal blocks until the completion object is completed.

 Then add the second goal execution to your project at the appropriate
 phase
 where you need the execution to have completed...

 for example if you start the threads in the process-sources phase, you
 might
 be happy to let them run in the background until the test phase has
 completed, but they must be finished by the time the package phase runs,
 so
 I would bind your execution of the second goal to the test phase

 -Stephen

 2009/10/28 Gajo Csaba csaba.g...@cosylab.com




 -
 To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
 For additional commands, e-mail: users-h...@maven.apache.org





 -
 To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
 For additional commands, e-mail: users-h...@maven.apache.org




 -
 To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
 For additional commands, e-mail: users-h...@maven.apache.org




Re: [Fwd: Threads in a plug-in]

2009-10-29 Thread Gajo Csaba
Which is the main class of maven? I found in 
org.apache.maven.cli.MavenCli this as the last line of the public static 
void main method, so maybe this is it:


System.exit( result );

Regards,
Csaba


Nick Stolwijk wrote:

I think Maven executes a System.exit at the end, which will terminate all
threads, regardless of daemon state.

With regards,

Nick Stolwijk
~Java Developer~

IPROFS BV.
Claus Sluterweg 125
2012 WS Haarlem
http://www.iprofs.nl


On Thu, Oct 29, 2009 at 1:09 PM, James Russo j...@halo3.net wrote:

  

Hello,

Actually it is the other way around. Daemon threads will not hold up JVM
from exiting, but non-deamon threads will.

Marks this thread as either a daemon thread or a user thread. The Java
Virtual Machine exits when the only threads running are all daemon threads.

The daemon flag will be set if the creating thread is a daemon thread.
Maybe force the setDaemon to false on the newly created thread and that may
give you desired effect.

-jr


Brian Fox wrote:



Maven just exits when it's done and then the jdk pulls everything
down. Isn't there a flag you can set on a thread to mark it as a
daemon thread, and then the system waits before killing it?

On Wed, Oct 28, 2009 at 9:20 AM, Gajo Csaba csaba.g...@cosylab.com
wrote:


  

Good idea! I was actually hoping there was some switch I can set in Maven
to
tell it not to terminate my thread, but I guess your idea would work fine
as
well. Thanks!
Csaba


Stephen Connolly wrote:




add a second goal

the first goal will store some thread completion object in MavenSession
or
in a Class level static field

When all threads are finished the completion object will be updated by
the
last thread

The second goal blocks until the completion object is completed.

Then add the second goal execution to your project at the appropriate
phase
where you need the execution to have completed...

for example if you start the threads in the process-sources phase, you
might
be happy to let them run in the background until the test phase has
completed, but they must be finished by the time the package phase runs,
so
I would bind your execution of the second goal to the test phase

-Stephen

2009/10/28 Gajo Csaba csaba.g...@cosylab.com




  

-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org






-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



  

-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org





  



-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



[Fwd: Threads in a plug-in]

2009-10-28 Thread Gajo Csaba

Hello all,

Could someone please answer my question? I don't believe it's that 
complicated...


Thanks, Csaba


---BeginMessage---

Hello,

I've developed a plug-in which executes some shell commands. I would 
like to run these commands in parallel with the rest of the build 
process, because they don't affect the other files. So I was thinking of 
creating a thread in the execute() method, starting it, and let it do 
its job. The problem is this works for some time, and Maven keeps on 
doing its job, but if Maven's lifecycle ends before the thread has 
finished its job, then the thread will be terminated as well.


Is there a way to instruct Maven to not terminate until the thread has 
finished, or at least to not terminate the thread itself?


Thanks, Csaba




-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org


---End Message---

-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Re: [Fwd: Threads in a plug-in]

2009-10-28 Thread Stephen Connolly
add a second goal

the first goal will store some thread completion object in MavenSession or
in a Class level static field

When all threads are finished the completion object will be updated by the
last thread

The second goal blocks until the completion object is completed.

Then add the second goal execution to your project at the appropriate phase
where you need the execution to have completed...

for example if you start the threads in the process-sources phase, you might
be happy to let them run in the background until the test phase has
completed, but they must be finished by the time the package phase runs, so
I would bind your execution of the second goal to the test phase

-Stephen

2009/10/28 Gajo Csaba csaba.g...@cosylab.com

 Hello all,

 Could someone please answer my question? I don't believe it's that
 complicated...

 Thanks, Csaba



 Hello,

 I've developed a plug-in which executes some shell commands. I would like
 to run these commands in parallel with the rest of the build process,
 because they don't affect the other files. So I was thinking of creating a
 thread in the execute() method, starting it, and let it do its job. The
 problem is this works for some time, and Maven keeps on doing its job, but
 if Maven's lifecycle ends before the thread has finished its job, then the
 thread will be terminated as well.

 Is there a way to instruct Maven to not terminate until the thread has
 finished, or at least to not terminate the thread itself?

 Thanks, Csaba




 -
 To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
 For additional commands, e-mail: users-h...@maven.apache.org




 -
 To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
 For additional commands, e-mail: users-h...@maven.apache.org



Re: [Fwd: Threads in a plug-in]

2009-10-28 Thread Gajo Csaba
Good idea! I was actually hoping there was some switch I can set in 
Maven to tell it not to terminate my thread, but I guess your idea would 
work fine as well. Thanks!

Csaba


Stephen Connolly wrote:

add a second goal

the first goal will store some thread completion object in MavenSession or
in a Class level static field

When all threads are finished the completion object will be updated by the
last thread

The second goal blocks until the completion object is completed.

Then add the second goal execution to your project at the appropriate phase
where you need the execution to have completed...

for example if you start the threads in the process-sources phase, you might
be happy to let them run in the background until the test phase has
completed, but they must be finished by the time the package phase runs, so
I would bind your execution of the second goal to the test phase

-Stephen

2009/10/28 Gajo Csaba csaba.g...@cosylab.com

  


-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Threads in a plug-in

2009-10-27 Thread Gajo Csaba

Hello,

I've developed a plug-in which executes some shell commands. I would 
like to run these commands in parallel with the rest of the build 
process, because they don't affect the other files. So I was thinking of 
creating a thread in the execute() method, starting it, and let it do 
its job. The problem is this works for some time, and Maven keeps on 
doing its job, but if Maven's lifecycle ends before the thread has 
finished its job, then the thread will be terminated as well.


Is there a way to instruct Maven to not terminate until the thread has 
finished, or at least to not terminate the thread itself?


Thanks, Csaba




-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org