|
74 | 74 | protected boolean completed;
|
75 | 75 |
|
76 | 76 | protected ResourceDownloader current_downloader;
|
77 |
| - protected Object result; |
| 77 | + protected volatile Object result; |
78 | 78 | protected AESemaphore done_sem = new AESemaphore("RDTorrent");
|
79 | 79 |
|
80 | 80 | public
|
|
549 | 549 | }
|
550 | 550 | });
|
551 | 551 |
|
552 |
| - Thread t = |
553 |
| - new AEThread( "RDTorrent percentage checker") |
554 |
| - { |
555 |
| - @Override |
556 |
| - public void |
557 |
| - runSupport() |
558 |
| - { |
559 |
| - int last_percentage = 0; |
| 552 | + AEThread2.createAndStartDaemon( "RDTorrent percentage checker",()->{ |
560 | 553 |
|
561 |
| - while( result == null ){ |
| 554 | + int last_percentage = 0; |
562 | 555 |
|
563 |
| - int this_percentage = download.getStats().getDownloadCompleted(false)/10; |
| 556 | + while( result == null ){ |
564 | 557 |
|
565 |
| - long total = torrent.getSize(); |
| 558 | + int this_percentage = download.getStats().getDownloadCompleted(false)/10; |
566 | 559 |
|
567 |
| - if ( this_percentage != last_percentage ){ |
| 560 | + if ( this_percentage != last_percentage ){ |
568 | 561 |
|
569 |
| - reportPercentComplete( ResourceDownloaderTorrentImpl.this, this_percentage ); |
| 562 | + reportPercentComplete( ResourceDownloaderTorrentImpl.this, this_percentage ); |
570 | 563 |
|
571 |
| - last_percentage = this_percentage; |
572 |
| - } |
| 564 | + last_percentage = this_percentage; |
| 565 | + } |
573 | 566 |
|
574 |
| - try{ |
575 |
| - Thread.sleep(1000); |
| 567 | + try{ |
| 568 | + Thread.sleep(1000); |
576 | 569 |
|
577 |
| - }catch( Throwable e ){ |
| 570 | + }catch( Throwable e ){ |
578 | 571 |
|
579 |
| - Debug.printStackTrace( e ); |
580 |
| - } |
581 |
| - } |
| 572 | + Debug.printStackTrace( e ); |
582 | 573 | }
|
583 |
| - }; |
584 |
| - |
585 |
| - t.setDaemon( true ); |
586 |
| - |
587 |
| - t.start(); |
| 574 | + } |
| 575 | + }); |
| 576 | + |
588 | 577 |
|
589 | 578 | int state = download.getState();
|
590 | 579 |
|
|
594 | 583 |
|
595 | 584 | download.start();
|
596 | 585 |
|
597 |
| - }else if ( state == Download.ST_SEEDING ){ |
| 586 | + }else if ( state == Download.ST_SEEDING || download.isComplete()){ |
598 | 587 |
|
599 | 588 | // its possible that the d/l has already occurred and it is seeding!
|
600 | 589 |
|
|
0 commit comments