Description:Code optimization

Feature or Bugfix:Bugfix
Binary Source:No

Signed-off-by: lwx1281857 <linnanmu@h-partners.com>
This commit is contained in:
lwx1281857 2024-06-20 20:34:21 +08:00
parent efc7036e2c
commit f99440f446
3 changed files with 3 additions and 3 deletions

View File

@ -147,7 +147,7 @@ void DeviceInfoService::OnStart(void)
DINFO_LOGE("DeviceInfoService Publish failed");
}
threadStarted_ = true;
std::thread(&DeviceInfoService::ThreadForUnloadSa, this).detach();
std::thread([this] {this->ThreadForUnloadSa();});
return;
}

View File

@ -53,7 +53,7 @@ void WatcherManagerKits::ResetService(const wptr<IRemoteObject> &remote)
delete threadForReWatch_;
}
stop_ = false;
threadForReWatch_ = new (std::nothrow)std::thread(&WatcherManagerKits::ReAddWatcher, this);
threadForReWatch_ = new (std::nothrow)std::thread([this] {this->ReAddWatcher();});
WATCHER_CHECK(threadForReWatch_ != nullptr, return, "Failed to create thread");
}
}

View File

@ -300,7 +300,7 @@ void WatcherManager::RunLoop()
void WatcherManager::StartLoop()
{
if (pRecvThread_ == nullptr) {
pRecvThread_ = new (std::nothrow)std::thread(&WatcherManager::RunLoop, this);
pRecvThread_ = new (std::nothrow)std::thread([this] {this->RunLoop();});
WATCHER_CHECK(pRecvThread_ != nullptr, return, "Failed to create thread");
}
}