locking

In Perl, how can I wait for threads to end in parallel?

半世苍凉 提交于 2019-11-30 03:31:00
问题 I have a Perl script that launches 2 threads,one for each processor. I need it to wait for a thread to end, if one thread ends a new one is spawned. It seems that the join method blocks the rest of the program, therefore the second thread can't end until everything the first thread does is done which sort of defeats its purpose. I tried the is_joinable method but that doesn't seem to do it either. Here is some of my code : use threads; use threads::shared; @file_list = @ARGV; #Our file list

How to detect if PIN/password/pattern is required to unlock phone?

谁都会走 提交于 2019-11-30 03:24:39
How can I detect if the phone is locked by a password, pin or pattern? thank you! Two methods Check programatically - API 16+ https://gist.github.com/doridori/54c32c66ef4f4e34300f Note that you dont need to check for face unlock as that requires that a pin/pass fallback is set. Device Admin Policies Can also look into the Device Admin Policies which allow restrictions on how the app is setup regarding security including pin/pass set restrictions Device Administration Enhancing Security with Device Management Policies As an aside, these are the lock types you want to check for if using an

Difference between lock(this) and a lock on static object

隐身守侯 提交于 2019-11-30 02:59:24
问题 Which of the following two code snippets is better to use? static readonly object _locker = new object(); lock (_locker) or lock (this) this is an object of the current instance. So why is lock (_locker) always in the books? Related: What is the difference between lock(this) and lock(thisLock)? Why is lock(this) {…} bad? 回答1: There could be a big difference. The biggest difference between the two is that the first example uses a single object to lock on (hence the static keyword) while the

Intel 64 and IA-32 | Atomic operations including acquire / release semantic

廉价感情. 提交于 2019-11-30 02:29:22
According to the Intel 64 and IA-32 Architectures Software Developer's Manual the LOCK Signal Prefix "ensures that the processor has exclusive use of any shared memory while the signal is asserted". That can be a in the form of a bus or cache lock. But - and that's the reason I'm asking this question - it isn't clear to me, if this Prefix also provides any memory-barrier. I'm developing with NASM in a multi-processor environment and need to implement atomic operations with optional acquire and/or release semantics. So, do I need to use the MFENCE, SFENCE and LFENCE instructions or would this

Java File Locking

放肆的年华 提交于 2019-11-30 01:42:23
问题 I have several threads (some of which are spawned by Process X, others by Process Y, et cetera ), and each thread needs to write to a file MyFile . However, if Thread T1 starts writing to MyFile first, then, when Thread T2 starts writing, it needs to wait for T1 to release the file , so that it can read the contents that were written in Thread T1 . In other words, each thread would have a finalizeThread method, like so: private void finalizeThread() { File f = new File("MyFile.dat"); f

How do I copy a file or folder that is locked under windows programmatically?

做~自己de王妃 提交于 2019-11-30 01:40:57
问题 What are the API calls to copy a file that is currently locked. I'm hoping to be able to use .Net, but Win32 calls would be fine as well. Please feel free to chime in about the same functionality on Unix, or any other OS. 回答1: You can use the VSS (Volume Shadow Copy Service, not Visual SourceSafe) API for this purpose. While powerful, this isn't exactly an easy-to-use API: the Overview of Processing a Backup Under VSS should give you an idea what's involved. Even though it's a relatively

Forcing closed an open file by C#

核能气质少年 提交于 2019-11-30 01:13:25
问题 I found a similar question here but it was closed/accepted with an answer of "don't do that". I'm in a situation where I don't care what happens to the other applications, I want to take a file that may be locked by others (rudely if needed) and have my way with it. I may need to move, rename, or delete this file. Basically I need to process files in a directory that is created by an app that doesn't clean up it's locks. I know the app is done processing when mine calls, but I need to kill

Show all current locks from get_lock

半城伤御伤魂 提交于 2019-11-30 01:08:49
Is there any way to select / show all current locks that have been taken out using the GET_LOCK function ? Note that GET_LOCK locks are different from table locks, like those acquired with LOCK TABLES - readers who want to know how to see those locks should read Detecting locked tables (locked by LOCK TABLE) Starting with MySQL 5.7, the performance schema exposes all metadata locks, including locks related to the GET_LOCK() function. See http://dev.mysql.com/doc/refman/5.7/en/metadata-locks-table.html SHOW FULL PROCESSLIST; You will see the locks in there From MySQL 5.7 onwards, this is

View isolation level for a query in mysql

江枫思渺然 提交于 2019-11-30 00:08:04
How do I determine the isolation level in use for a given query? After a query is executed (by a 3rd party application) I'd like to know which isolation level was used (e.g., read uncommitted). To be clear, I'm currently working on an application that uses EF4 running against mysql 5.1. I'm try to test different coding patterns to change isolations levels for specific EF4 queries. I need to be able to test and make sure the isolation levels are being set correctly. RolandoMySQLDBA SHOW VARIABLES LIKE 'tx_isolation'; or if you have MySQL 5.1+ SELECT * FROM information_schema.session_variables

T-SQL: Lock a table manually for some minutes [duplicate]

南楼画角 提交于 2019-11-30 00:06:27
This question already has an answer here: Forcing a query timeout in SQL Server 4 answers I know this will be strange, but I want to trigger an error in my MVC application and this error will be based on a LINQ Query, where I would like to get one record from a table. While this record will be blocked (database/table/row) level using T-SQL commands (for example an infinite loop always updating this one record) then my LINQ Query will execute a query to read that record. When LINQ tries then the result should be a time out after 20-30 seconds, anybody has tried this before? Marty If I