Hi all,

 

In 2009-06-08 I opened a post with that content:

 

===========

I use jsch to transfer data via sftp from one server to another.

I noticed that there remain some deamon(?) threads after data-transfers.

 

...com.jcraft.jsch.Session.run(Session.java:1193)

java.lang.Thread.run(Thread.java:619)....

 

I close every connection using a own disconnect-method in this way:

 

 

public void disconnect() {

        if ( sftpConnection != null ) {

               sftpConnection.disconnect();

               sftpConnection = null;

        } 

        if ( sftpSession != null ) {

               sftpSession.disconnect(); 

               sftpSession = null;

        } 

}

 

 

Maybe I do a mistake to close the session properly.

What's the right way to avoid such waiting threads ?

===========

 

 

So today there's still the same problem but now I can reproduce the
problem with a small test-application and now I can show a thread-dump
for that moment.

That's the reproducable situation:

I have an application with a main-tread within I start a new thread for
every sftp-connection to list the directory on a remote host.

After listing is gone, there's still a thread for each connection?! I
close connection with the disconnect() method above, but a thread is
still alive.

 

That's the thread-dump in the situation for two connections. 

 

 

~~~~~~~~~~~~~ thread dump ~~~~~~~~~~~~~~

C:\Programme\Java\jdk1.6.0_16\bin>jstack 6140

2010-04-13 11:46:47

Full thread dump Java HotSpot(TM) Client VM (14.2-b01 mixed mode):

 

"Connect thread myHost session" prio=6 tid=0x0b062800 nid=0x1304
runnable [0x0b

20f000]

   java.lang.Thread.State: RUNNABLE

        at java.net.SocketInputStream.socketRead0(Native Method)

        at java.net.SocketInputStream.read(SocketInputStream.java:129)

        at com.jcraft.jsch.IO.getByte(IO.java:82)

        at com.jcraft.jsch.Session.read(Session.java:811)

        at com.jcraft.jsch.Session.run(Session.java:1195)

        at java.lang.Thread.run(Thread.java:619)

 

"Connect thread myHost session" prio=6 tid=0x0b02b800 nid=0x634 runnable
[0x0b1

bf000]

   java.lang.Thread.State: RUNNABLE

        at java.net.SocketInputStream.socketRead0(Native Method)

        at java.net.SocketInputStream.read(SocketInputStream.java:129)

        at com.jcraft.jsch.IO.getByte(IO.java:82)

        at com.jcraft.jsch.Session.read(Session.java:811)

        at com.jcraft.jsch.Session.run(Session.java:1195)

        at java.lang.Thread.run(Thread.java:619)

 

"Low Memory Detector" daemon prio=6 tid=0x0aab8400 nid=0x740 runnable
[0x0000000

0]

   java.lang.Thread.State: RUNNABLE

 

"CompilerThread0" daemon prio=10 tid=0x0aab6000 nid=0xdc8 waiting on
condition [

0x00000000]

   java.lang.Thread.State: RUNNABLE

 

"JDWP Command Reader" daemon prio=6 tid=0x0aaa8c00 nid=0xb20 runnable
[0x0000000

0]

   java.lang.Thread.State: RUNNABLE

 

"JDWP Event Helper Thread" daemon prio=6 tid=0x0aaa7000 nid=0x1708
runnable [0x0

0000000]

   java.lang.Thread.State: RUNNABLE

 

"JDWP Transport Listener: dt_socket" daemon prio=6 tid=0x0aaa4800
nid=0x598 runn

able [0x00000000]

   java.lang.Thread.State: RUNNABLE

 

"Attach Listener" daemon prio=10 tid=0x0aa99400 nid=0x1668 waiting on
condition

[0x00000000]

   java.lang.Thread.State: RUNNABLE

 

"Signal Dispatcher" daemon prio=10 tid=0x0aa98000 nid=0xce8 runnable
[0x00000000

]

   java.lang.Thread.State: RUNNABLE

 

"Finalizer" daemon prio=8 tid=0x0aa89000 nid=0x16e0 in Object.wait()
[0x0abff000

]

   java.lang.Thread.State: WAITING (on object monitor)

        at java.lang.Object.wait(Native Method)

        - waiting on <0x02e8d448> (a java.lang.ref.ReferenceQueue$Lock)

        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)

        - locked <0x02e8d448> (a java.lang.ref.ReferenceQueue$Lock)

        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)

        at
java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

 

"Reference Handler" daemon prio=10 tid=0x0aa84400 nid=0x13d4 in
Object.wait() [0

x0abaf000]

   java.lang.Thread.State: WAITING (on object monitor)

        at java.lang.Object.wait(Native Method)

        - waiting on <0x02e8d1f8> (a java.lang.ref.Reference$Lock)

        at java.lang.Object.wait(Object.java:485)

        at
java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)

        - locked <0x02e8d1f8> (a java.lang.ref.Reference$Lock)

 

"main" prio=6 tid=0x00376c00 nid=0x16c0 runnable [0x0090f000]

   java.lang.Thread.State: RUNNABLE

        at de.juris.MainClass.main(MainClass.java:51)

 

"VM Thread" prio=10 tid=0x0aa80400 nid=0xf4c runnable

 

"VM Periodic Task Thread" prio=10 tid=0x0aaba400 nid=0x156c waiting on
condition

 

 

JNI global references: 2153

~~~~~~~~~~~~~~~ END ~~~~~~~~~~~~~~~~~~~~~~~~~

 

I hope that helps and I hope that someone can explain the problem or my
mistake and of course a solution ;-)

 

 

Thanks,

Markus

 

 

 

 

 

 

 

 

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to