像read()这样的I / O方法如何在java中将Thread置于阻塞状态?(How does I/O-methods like read() put a Thread in blocked state in java?)
所以,如果我已经正确地理解了这一点,当我们在一个对象上调用wait时,一个线程进入等待状态,当它等待一个对象的锁定时它会进入阻塞状态(比如当试图进入同步块或方法时) )。
像read()这样的I / O方法如何将线程置于阻塞状态? 我明白为什么它必须处于阻塞状态,等待它可以读取的数据,但我也对HOW感兴趣。 当JVM尝试读取的资源再次可用时,JVM如何通知线程它可以继续?
So, if i have understood this correctly, a thread goes into waiting state when we call wait on an object and it goes into blocked state when it is waiting for a lock on an object(like when trying to get into a synchronized block or method).
How does I/O-methods like read() put a Thread in a blocked state though? I understand WHY it has to be in a blocked state, waiting for data that it can read but i'm also interested in HOW. How does the JVM notify the thread that it can continue when data in the resource its trying to read, is available again?
原文:https://stackoverflow.com/questions/41141834
最满意答案
添加一个“。” 改为文件夹名称的开头。
BTW哪个手机给你这个问题。 我的猜测是,你看到了库中的旧缓存文件
Add a "." to the beginning of folder name instead.
BTW which phone is giving u this issue. My guess is that ur seeing old cached files in the Gallery
相关问答
更多-
Android:.nomedia被忽略,图片仍然出现在图库中(Android: .nomedia is ignored, images still appear on the gallery)[2023-02-07]
添加一个“。” 改为文件夹名称的开头。 BTW哪个手机给你这个问题。 我的猜测是,你看到了库中的旧缓存文件 Add a "." to the beginning of folder name instead. BTW which phone is giving u this issue. My guess is that ur seeing old cached files in the Gallery -
尝试下面的代码。 它在棒棒糖为我工作,希望为你工作 ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.DATA,"file path"); values.put(MediaStore.Images.Media.MIME_TYPE,"image/jpeg"); mContext.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CO ...
-
我认为这是由Gallery在幻灯片动画上设置的动画插值器引起的。 过冲插补器将导致该行为。 如果你想覆盖它,我不确定它会有多容易。 我做了一个快速搜索,但我找不到任何可以让你轻松覆盖Gallery的默认插值器的东西。 我唯一能找到的就是这篇帖子,有人似乎通过创建一个扩展Android Gallery类的新Gallery类来取得成功,以覆盖默认的插补器。 Had to extend gallery, I think the issue had something to do with a timer that ...
-
最后在http://groups.google.com/group/android-developers/browse_thread/thread/c1a385226f3df482上找到了它。 这是一个单行: sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse ("file://" + Environment.getExternalStorageDirectory()))); Finally found it at http:// ...
-
这可能不是最优雅的方式,但我发现它非常有用。 将帖子ID传递给下面的函数将从该帖子的post_content加载一个库。 因此,您将创建一个库并将其插入到您的帖子内容中,然后在模板中运行此功能,并将返回该库中的一系列附件,您可以随意使用,即幻灯片等。 function wp_load_gallery($post_id) { $post = get_post( $post_id ); $regx = '/' . get_shortcode_regex() . '/'; preg_match( $r ...
-
我的观察是Android画廊根据他们的新近度显示图像。 对于无法确定订单的设备,您可以从库中导入图像并检查其创建时间。 这是一种方法 。 或者您可以使用元数据提取器应用程序,可以找到许多罐子。 现在,您可以按照新近度的顺序排列图像,您应该完成。 [编辑] 我有个问题。 您说他们可能会以任何顺序被选中,他们是否通过“共享”将其“上传”到服务器上? 如果是这样,那么一种方法是检查上传的图像,或者如果你想要选择的顺序,你可以这样做。 编辑图像的元数据,必然会有一个无用的标签,选择一个并在触摸时编辑它。 因此,如果 ...
-
创建一个名为ExifUtils的类 public class ExifUtils { /** * @see http://sylvana.net/jpegcrop/exif_orientation.html */ public static Bitmap rotateBitmap(String src, Bitmap bitmap) { try { int orientation = getExifOrientation(src); if (orientatio ...
-
您可以使用ViewPager 有关一些好的链接,请参阅android viewPager实现 ,以了解如何实现它。 I ended up creating a simple implementation of my own: public class PicView extends View{ private int mBackgroundPicPosition; private Bitmap mBackgroundPic; private int m_touchStartPosX; private Ev ...
-
Android开放图库应用(Android open gallery app)[2023-07-07]
根据您的要求,您最好的选择是告诉Android不要在您的任务历史记录中保存图库。 这样,当他们离开Gallery活动时,它将不会出现在任务的历史堆栈中。 通过在意图上设置标志来做到这一点。 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("content://media/internal/images/media")); intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); startActiv ... -
用它来将图像添加到图库中 MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "your title"," your description") 或者如果你想插入则使用它,然后从中获取路径 String path=MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "your title","your description").toS ...