我有一个Android应用程序,我正在将数据检索到Fragment中.我相信Firebase可以管理其异步调用.但我仍然怀疑我们是否需要在后台线程中编写Firebase代码?
如果我们需要将它写入后台线程,那么请告诉您哪些操作需要更多时间.例如:
mDatabase = FirebaseDatabase.getInstance().getReference().child("Blog");
Run Code Online (Sandbox Code Playgroud)
我认为在主UI线程上执行此操作可能会充满风险,因为设置数据库之间的连接可能需要花费很长时间.
我编写了一个程序来反转字符串,其中字符串是一个字符数组.该计划是:
#include<iostream>
void rev(char *str)
{
char *end;
end = str;// end will now point to the same address of str
// now we need to incremet the end pointer upto it encounter null
if(str)// this checks if the string is present or not
{
while(*end)
++end;
--end;// set one character back, since last character is null
// swap characters from start of string with the end of the string
// until the pointers meet in middle.
while(str < end) …Run Code Online (Sandbox Code Playgroud)