Threading in Java: How to lock an object?

前端 未结 7 705
长发绾君心
长发绾君心 2020-12-29 03:33

The following Function is executing in its own thread:

private void doSendData()
{
    try {

           //writeToFile(); // just a temporary location of a c         


        
7条回答
  •  执念已碎
    2020-12-29 04:23

    To avoid that error message, use the synchronized keyword:

    synchronized(serverAddr){
      serverAddr.wait(60000);
    }
    

提交回复
热议问题