一些基础知识回顾

  1. 线程创建于销毁
pthread_t tid;
pthread_create(&tid, NULL, &fun, NULL);

void* fun(void* par) {
  JNIVM* vm;
  vm = from_JniOnload();
   JNIEnv* env;
  int ret = vm->AttachCruuentThread(&env, NULL);
  if (ret != JNI_OK) {
    vm->detachCurrentThread();
    env = NULL;
    pthread_detach(pthread_self());
    pthread_exit((void*)0);
  }
   ...
}
  1. 文件流读写
File file = new File(ctx.getExternalCacheDir(), "p.txt");
FileOutputStream fileOutputStream = new FileOutputStream(file);
byte[] buffer = new byte[2048];
fos.write(buffer, 0, buffer);

FileInputStream fis = new FileInputStream(file);
while (len = fis.read(buffer) > 0) {
  fos.write(buffer, 0, len);
}

你可能感兴趣的:(一些基础知识回顾)