首页 \ 问答 \ 像read()这样的I / O方法如何在java中将Thread置于阻塞状态?(How does I/O-methods like read() put a Thread in blocked state in java?)

像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
更新时间:2023-09-01 17:09

最满意答案

添加一个“。” 改为文件夹名称的开头。

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

相关问答

更多
  • 添加一个“。” 改为文件夹名称的开头。 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不要在您的任务历史记录中保存图库。 这样,当他们离开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 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。