⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 get.c

📁 初级学习资料必读本
💻 C
字号:
#include <stdio.h>#include <string.h>#include <stdlib.h>#include "CubbyHole.h"JNIEXPORT jint JNICALL Java_CubbyHole_get(JNIEnv *env, jobject obj) {   jint contents;   jint ret, available;   jref objref;   jclass cubbyclass, langclass, exceptclass;   jmethodID notifyid, waitid, exceptid;   jfieldID availid, contentid;   jobject exceptobj;   cubbyclass = (*env)->GetObjectClass(env, obj);   objref = cubbyclass;   langclass = (*env)->FindClass(env, "java/lang/Object");   notifyid = (*env)->GetMethodID(env, langclass, "notify", "()V");   waitid = (*env)->GetMethodID(env, langclass, "wait", "()V");   availid = (*env)->GetFieldID(env, cubbyclass, "available", "I");   ret = (*env)->MonitorEnter(env, obj);	   available = (*env)->GetIntField(env, obj, availid);   while (available == 0) {      (*env)->CallVoidMethod(env, obj, waitid);      available = (*env)->GetIntField(env, obj, availid);   }   (*env)->SetIntField(env, obj, availid, 0);   contentid = (*env)->GetFieldID(env, cubbyclass, "contents", "I");   contents = (*env)->GetIntField(env, obj, contentid);   (*env)->CallVoidMethod(env, obj, notifyid);       ret = (*env)->MonitorExit(env, obj);   return (contents);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -