concurrency

updating jlabel

非 Y 不嫁゛ 提交于 2019-12-25 05:14:44
问题 I am having trouble updating a jlabel in a method. here is my code: JLabel curStatus = new JLabel(""); JButton jbtnSubmit; public static void main(String[] args) { test gui = new test(); gui.startGUI(); // gui.setCurStatus("testing!"); << seems to work here, //but when i call it from another class, it doesn't want to run. } // Set up the GUI end for the user public void startGUI() { // These are all essential GUI pieces new JTextArea(""); final JFrame jfrm = new JFrame("my program"); jfrm

python concurrent ProcessPoolExecutor not working on Raspberry Pi (idle python 3.4.2)

眉间皱痕 提交于 2019-12-25 04:49:06
问题 I am trying to use multi-processing in a share price machine learning application running on raspberry pi 3 (4 cores). Here is some code which illustrates the problem: from concurrent import futures def some_function(x): return x + 1 def main_function(some_list): with futures.ProcessPoolExecutor() as executor: results = executor.map(some_function, some_list) return results if __name__ == '__main__': print(main_function([1, 2, 3])) When I run this, I immediately get a message saying the

design of a Producer/Consumer app

半世苍凉 提交于 2019-12-25 04:34:22
问题 I have a producer app that generates an index (stores it in some in-memory tree data structure). And a consumer app will use the index to search for partial matches. I don't want the consumer UI to have to block (e.g. via some progress bar) while the producer is indexing the data. Basically if the user wishes to use the partial index, it will just do so. In this case, the producer will potentially have to stop indexing for a while until the user goes away to another screen. Roughly, I know I

Java JDBC Primary Key Oracle Database

六眼飞鱼酱① 提交于 2019-12-25 04:26:06
问题 I am developing an application using Java and I have an Oracle database. To store data I am using JDBC. In Oracle database, there is nothing like a Auto Increment. So I have used triggers to get the lastest primary key. Currently the application has been implemented and I get the saved primary key back. This happens when the connection.setAutoCommit(true) is set. What I would like to know if I set the connection.setAutoCommit(false) is it possible to get the primary key? The reason why I ask

Distributed Application using Zookeeper

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 03:58:16
问题 I need to design distributed application using zookeeper. This is the first time I am using Zookeeper so I am little confused with its usage. I have read that Zab protocol ensures serializability when it comes to multiple updates but I am unable to understand, if that is the case than it will automatically allow lock free implementation. So why locks are needed in first place? It will be great if some one can help here. Thanks 回答1: Zab protocol is a critical PART of zookeeper.It ensures

ExecutorService - How to set values in a Runnable/Callable and reuse

别等时光非礼了梦想. 提交于 2019-12-25 02:01:57
问题 I want to use the ExecutorService to run a series of the same Runnable/Callable tasks. I've searched around for a tutorial or an example, but nothing that involves actually setting the value of an existing Runnable/Callable object and then using submit() to send that object back into the ExecutorService. Basically, here's what I want to do: Get a list of servers. Iterate thru the list of servers, calling InetAddress.getByName(host) to grab data on each host. Collect that data into Server

Is volatile needed for a lazy boolean shutdown flag in Java?

落花浮王杯 提交于 2019-12-25 01:47:11
问题 Assume the following code public class Singleton { boolean shuttingDown = false; void action() { if (shuttingDown) { throw new RuntimeException("already shutting down"); } // do some more stuff } // Called by a single thread only void onShutDown() { shuttingDown = true; // perform some more actions to remedy the class } } Basically I want to block all upcoming calls to action() with an exception. I know that setting shuttingDown is an atomic operation. However the question is if I would need

CoreData crash with main queue context set as child of private queue context

两盒软妹~` 提交于 2019-12-25 01:05:43
问题 My problems goes like this. I want to async saves to disk. The code to setup core data stack looks like this. - (NSManagedObjectContext *)managedObjectContext { NSPersistentStoreCoordinator *coordinator = self.persistentStoreCoordinator; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ NSManagedObjectContext *privateMOC = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType]; [privateMOC setPersistentStoreCoordinator:coordinator]; _

Concurrent usage of an EJB that is exposed as RMI service

a 夏天 提交于 2019-12-25 00:37:24
问题 I have built an application which simulates several clients using the same RMI service. This service is then invoked concurrently by every client retrieving and uploading data to the server. My concern is if every remove invocation takes some time does the remote service implementation (jBoss 5 EJB) can handle these calls remotely or it serializes them down. If the latter is the case then I have to limit the number of clients to prevent slowing them down. 回答1: RMI calls are not sequentialized

Calling in the constructor a method outside with the parameter this of the object/constructor

老子叫甜甜 提交于 2019-12-25 00:34:25
问题 hey i saw this topic here: Can I call methods in constructor in Java? My Question is smilar, but a little bit different. I want to know whats happening, if i call from a constructor from class A something outside of that from class B with this from A. In my example below A is JobImpl , and B is that queue in Scheduler. class JobImpl implements Job { public JobImpl(Scheduler s, JobHandler runJob, boolean advancedWaitOnCancel, boolean oneShot) { this.s = s; this.runJob = runJob; this