Click here to Skip to main content
14,035,518 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
I wrote a class that sends some content thrugh the net. I had some issuse because a file sending didn't ended after more than 10 hours, I think for connection interruptions.

What I have tried:

I though to put the sender method into a different thread and try to interrupt it after a timeout if it wasn't ended yet. But the issue is inside a kernel class, and I cannot put into it a query to check if Therad.isinterrupted is checked.

Can I truncate a thread without ask him to terminate via the interrupt method?

Thank you, Lucio Menci
Posted
Updated 16-Apr-19 3:14am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Given appropriate security settings for the calling and the receiving threads, it is possible to use the interrupt() method to signal your worker thread. You will still have to check the state of the interrupt using the isinterrupted() method, so this will not help with a clean exit from kernel mode.

One method would be to divide the file to be sent into small chunks, and send each chunk with a timeout. If the send fails, or if the isinterrupted() method returns true, the worker thread can clean up and exit.
   
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Thank you for reply.

My problem is that I send hundreds files of about 100 bytes, under AS400 o.s..
My super send them using a PrintWriter directed to a java.net.URL([...]).openConnection().getOutputStream(), and writing into it via a println.

If there is a connection interruption during the println, and it is off over than 30 seconds, the println is waiting for a kill of the process.

I'm afraid there are no solutions.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.190424.1 | Last Updated 16 Apr 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100