Should I reuse DatagramPacket?
问题 I am building a UDP-based application that receives and sends multiple packets. I could build a new DatagramPacket for each send, or I recycle one instance for the life of my application. Are there any advantages to reusing a DatagramPacket ? (e.g. memory-allocation) Are there any potential problems? (e.g. thread-safety) 回答1: It looks like you can't. I just tried sending the same DatagramPacket twice and I get the following behavior: The packet is sent only once Netty logs the warning below