Gradle sometimes stucks on resolving dependencies when called via ssh using jsch

Gradle Version: 2.4, 2.14.1, 3.1
Operating System and JVM version: Windows 8.1 x64, Windows 8.1 x32, JDK 1.8u60x64, 1.8u92x64
Is this a regression? If yes, which version of Gradle do you know it last worked for? NO

We are using java jsch (version 0.1.52) to run gradle task via ssh (using cygwin 2.1.0) on windows machine remotely. We have a problem that gradle nondeterministically stucks on resolving dependencies (often pom check or even gradle download using gradlew). Sometimes it happens 10 times in a row, sometimes once in 25 runs.

The observation is that in place of downloaded pom file there is .fslck file.

In jstack thread dump we can see that there may be a problem with some locks (thread dump below)
http://pastebin.com/0gnm1VnL