Click here to Skip to main content
15,077,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 16-Apr-19 3:14am

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.
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[...]).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)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900