Interrupt a thread in DatagramSocket.receive

前端 未结 3 1285
孤城傲影
孤城傲影 2020-12-17 09:03

I\'m building an application that listens on both TCP and UDP, and I\'ve run into some trouble with my shutdown mechanism. When I call Thread.interrupt() on eac

3条回答
  •  佛祖请我去吃肉
    2020-12-17 09:46

    DatagramSocket.receive blocks until it receives a datagram. Probably what you need to do is use setSoTimeout to make it timeout.

提交回复
热议问题