小编Mor*_*lau的帖子

在自动脚本中停止 Android 屏幕录制

我正在 Appium 中构建自动化测试场景(针对 Android 应用程序),并试图找出一种在特定时刻开始录制屏幕、运行一些操作然后停止录制的方法。

我找不到任何在 Appium 中实现的屏幕记录解决方案,但找到了一个简洁的 adb shell 命令,screenrecord它完全符合它的规定。现在我的问题是,停止录制的唯一明显方法是在参数中设置我需要的确切时间限制,或者在交互式 shell 中按 Ctrl-C:

2|shell@mako:/ $ screenrecord --help
Usage: screenrecord [options] <filename>

Android screenrecord v1.2.  Records the device's display to a .mp4 file.

Options:
--size WIDTHxHEIGHT
    Set the video size, e.g. "1280x720".  Default is the device's main
    display resolution (if supported), 1280x720 if not.  For best results,
    use a size supported by the AVC encoder.
--bit-rate RATE
    Set the video bit rate, in bits per second.  Value may …
Run Code Online (Sandbox Code Playgroud)

shell automation android adb appium

6
推荐指数
1
解决办法
4305
查看次数

HashMap 中唯一键的线程安全性

关于这个话题有很多讨论,例如这里:

ConcurrentHashMap 和 Collections.synchronizedMap(Map) 有什么区别?

但我还没有找到我的特定用例的答案。

通常,您不能假设 HashMap 是线程安全的。如果同时从不同的线程写入相同的密钥,一切都可能会崩溃。但是如果我知道我的所有线程都有唯一的键呢?

这段代码是线程安全的还是我需要添加阻塞机制(或使用并发映射)?

Map<int, String> myMap = new HashMap<>();
for (int i = 1 ; i > 6 ; i++) {
    new Thread(() -> {
        myMap.put(i, Integer.toString(i));
    }).start();
}
Run Code Online (Sandbox Code Playgroud)

java concurrency multithreading hashmap thread-safety

2
推荐指数
1
解决办法
49
查看次数