Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Basic question  RSS feed

 
Patrick Brahami
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a software, that creates new threads (background wise, since I'm using Timer / TimerTask classes), my proccess is, as I understand it, the 'main' thread, where I begin my program(it's a GUI class).

Now, if I close it are all the threads closes automatically? As I understand it should be so, although it seems like even after I closed my program the threads it has initiated are keep running.
(I schedule something to happen, and happens even if though I closed my program days ago. Weird no? )

Thanks in advance.
[ October 26, 2008: Message edited by: Patrick Brahami ]
 
Pavan Kumar Srinivasan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your main thread will NOT exit the application if any of the child threads are non Daemon Threads(User Threads) & are still running.
[ October 26, 2008: Message edited by: Pavan Kumar Srinivasan ]
 
Patrick Brahami
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Weird. I see, it's like the main application is just another thread and not the whole process.

Is there a way to user Timer with daemon threads instead of regular threads? I mean setting it so that the background created threads are daemon?

Thanks.
 
Henry Wong
author
Sheriff
Posts: 22840
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to user Timer with daemon threads instead of regular threads? I mean setting it so that the background created threads are daemon?


Take a look at the constructors for the Timer class. One of the constructors does exactly what you want.

Henry
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!