Results 1 to 1 of 1

Thread: runaway thread

  1. #1
    mac's Avatar
    mac is offline Member
    Join Date
    Dec 2009
    St. Petersburg, Russia
    Rep Power

    Default runaway thread

    Ok guys, this is really weird.

    Program continues to run after last line of the program executes.

    Some details
    Without flooding you with the code, accept the following as absolute truths:
    1. Debugging proved that every single line in a program has a chance to complete. Last } in main gets executed
    2. Program is supposed to exit naturally, most methods are boolean and either return true or throw exceptions. Program does not have explicit exit()
    3. After the last } debugger points to Thread.class

    Here is a hint at where i think the problem may be (I have confirmed that method finishes fine)

    Java Code:
    private boolean loadTargetFiles() {
    	Executor pool = Executors.newFixedThreadPool(5);
    	CompletionService<Properties> completition = new   ExecutorCompletionService<Properties>(pool);
    	for (String target : p.getTargetFiles()) {
    		completition.submit(new FileLoader(target, p.getOutputFile()));
    	for (int i = 0; i < p.getTargetFiles().length; i++) {
    		Properties r = null;
    		try {
    			r = completition.take().get();
    		catch (InterruptedException e) {
    		catch (ExecutionException e) {
    		if (r != null) {
    		return true;
    I have tested that once this method is done, Properties object is loaded, method does what it was written to do and waives bye.

    Should i somehow join() this thread? Is there any indication that i may be doing something wrong here?

    Please advise

    PS: After last } executes, this = Thread

    but what and why?
    Last edited by mac; 04-08-2010 at 01:07 AM.

Similar Threads

  1. Difference between Thread.yield() and Thread.sleep() methods
    By Nageswara Rao Mothukuri in forum New To Java
    Replies: 12
    Last Post: 07-30-2010, 06:37 PM
  2. Trigger main thread method from secondary thread?
    By DigitalMan in forum Threads and Synchronization
    Replies: 8
    Last Post: 01-26-2010, 03:13 AM
  3. Retry constructing a thread/ terminate thread
    By coyote1982 in forum New To Java
    Replies: 6
    Last Post: 09-17-2009, 10:38 AM
  4. Replies: 0
    Last Post: 01-28-2008, 08:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts