synchronization

When is it OK to use Thead.stop() in Java?

人走茶凉 提交于 2019-12-24 04:41:11
问题 The Java Docs for Thread.stop() make it sound like the world will end if you ever call Thread.stop(). Deprecated . This method is inherently unsafe. Stopping a thread with Thread.stop causes it to unlock all of the monitors that it has locked (as a natural consequence of the unchecked ThreadDeath exception propagating up the stack). If any of the objects previously protected by these monitors were in an inconsistent state, the damaged objects become visible to other threads, potentially

Securely store Android Firebase Auth users in a MySQL database

梦想的初衷 提交于 2019-12-24 04:18:08
问题 I am creating an Android native app and I am using Firebase Auth with multiple auth provides such as; Email, Facebook, Google etc, I will use the Firebase SDK for chat and real-time DB. I have a RESTful API with a MySQL (similar to Facebook with; friends, private and public posts), a user database behind a PHP server and I would like to synchronize the Auth so that I can ensure that the user is correct and has a authority to access data for which they have permissions. I am able to edit and

Securely store Android Firebase Auth users in a MySQL database

99封情书 提交于 2019-12-24 04:18:02
问题 I am creating an Android native app and I am using Firebase Auth with multiple auth provides such as; Email, Facebook, Google etc, I will use the Firebase SDK for chat and real-time DB. I have a RESTful API with a MySQL (similar to Facebook with; friends, private and public posts), a user database behind a PHP server and I would like to synchronize the Auth so that I can ensure that the user is correct and has a authority to access data for which they have permissions. I am able to edit and

Synchronizing a crowd in Java

孤者浪人 提交于 2019-12-24 03:35:10
问题 I'm writing a demo program to explain how to regulate the concurrency of a crowd of threads in Java, but the result is not as I expected. This is the code: package parcountSyncStat; public class Parcount extends Thread { private static int N=1000; private static Integer x=0; public static void main(String[] args) throws InterruptedException { Thread[] t = new Thread[N]; int i; for (i = N-1; i >= 0; i--) { t[i]=new Parcount(); t[i].start(); } for ( i=N-1; i>=0; i-- ) t[i].join(); System.out

Java FileWriter overwrite

橙三吉。 提交于 2019-12-24 03:24:46
问题 I have a piece of code that generates new data whenever there is new data available as InputStream . The same file is overwritten everytime. Sometimes the file becomes 0 kb before it gets written. A webservice reads these files at regular intervals. I need to avoid the case when the file is 0 bytes. How do it do this? Will locks help in this case? If the browser comes in to read a file which is locked, will the browser continue to show old data from the cache until the lock is released and

How concerned should we be about thread safety with JSF managed beans?

浪尽此生 提交于 2019-12-24 02:14:29
问题 I'm working on a JSF 1.2 project which has AJAX functionality on it's pages (using RichFaces). My bean builds a list of objects to be edited and then has methods to support the editing and the bean is session-scoped. I will be using a a4j:queue so that only one AJAX call can happen at a time. I'm curious if it is wise to use synchronization (locks on objects, or perhaps collections from java.util.concurrent) in the managed bean. Is the extra work needed to implement synchronization/thread

OpenGL Compute shader sync different work groups

时光毁灭记忆、已成空白 提交于 2019-12-24 01:19:52
问题 If you have a compute shader where different work groups in the same dispatch are put in a continuous loop and you want to signal them all to exit said loop by any of them setting a flag. Is this actually possible? I've tried using a flag in an SSBO marked both coherent and volatile to trigger their exit. Which sometimes doesn't work on AMD it seems. When one of the work groups wants to trigger all of them to exit I simply set the flag from zero to one directly (as it doesn't matter as long

Ways to synch many (small) files over high-latency network connection

女生的网名这么多〃 提交于 2019-12-24 01:15:24
问题 We typically deploy our software applications to our clients using Subversion (svn update on the clients; unidirectional). We're currently experiencing problems with one of our clients because of the high latency (large file download speeds are good) because they are in China and our server is in Canada. Subversion simply times out with an error after a very long period of time. Our application has lots of small files (.aspx, .config, etc.) and a few larger files (.dll, .jpg) for a total of

Do I need memory barrier for accessing memory modified by the thread that finished?

非 Y 不嫁゛ 提交于 2019-12-24 00:54:35
问题 [ Hereinafter, C++ terms ] I have a thread A and thread B that share access to the integer value P. Thread A initializes this value and updates it while running. Then thread A completes. Thread B waits for thread A to complete (standard OS API call, whatever OS is used) and wants to read P. Does thread B need a memory barrier to read a coherent, last set by thread A, value of P? Is there a possibility that when OS API says "thread A finished", the changes of memory it modified are not visible

Implementation of monitors with semaphores

ぐ巨炮叔叔 提交于 2019-12-24 00:47:23
问题 I've been asked the following question and I'm not sure what the correct answer is to it: If monitors are implemented by replacing condition variables with semaphores (counters set to 0) with down() and up() as wait and signal, respectively, would the monitors work correctly? I'd be tempted to say it is a correct implementation because semaphores and condition variables can replace each other, correct? Is there a better explanation? 回答1: You are asking about a semaphore initialized to 1,