multithreading

Java SwingWorker while using SWT

杀马特。学长 韩版系。学妹 提交于 2020-01-22 03:50:07
问题 I have a problem as follows: I've written a simple minimalistic Application that utilizes the SWT for the GUI. In a specific tab, where it displays a table that get's filled with Informition via a REST Api Call. Additionaly, i have another method to export this table into a CSV-file. This works absolutely fine. Now I need some kind of autoupdate/-export for which I implemented a Swing-Worker like this: protected class AutoExportWorker extends SwingWorker<Integer, String> { @Override public

I keep getting this error: “Invalid attempt to call Read when reader is closed”

落花浮王杯 提交于 2020-01-22 03:26:06
问题 Here is my code, I close and open the reader and it's still not working. A few threads can access this function concurrently but there is a lock. It works a few times in the beginning but sooner or later I get the exception 'Invalid attempt to call Read when reader is closed' at private IList<BursaUser> GetUsers(SqlCommand cmd) { IList<User> users = new List<User>(); User user; lock (thisLock) { SqlDataReader dr = null; try { Conn.Open(); dr = cmd.ExecuteReader(CommandBehavior.CloseConnection

is it possible to define execution order for a set of threads in java

谁说我不能喝 提交于 2020-01-22 03:09:12
问题 My understanding is that threads in theory are executed in parallel. JVM decides; when a resource is available which thread to pick from the waiting thread queue (based on some algorithm). Hence we can not provide/enforce a sequence of execution for threads. Say my java application has 3 threads, t1, t2 and t3. For some specific reason; I want the threads to execute in this order: t3 then t1 and then t2. Is it possible to do this? Does java provided any way of doing this? 回答1: Use an Executor

How to run with various number of user at different times in Jmeter

China☆狼群 提交于 2020-01-22 03:01:11
问题 I want to run login request with different number of users: 10, 20, 30 and generate report with number of users, and response time. I created CSV file with number of threads: 10, 20, 30 I assigned thread number variable into Number of Thread in Thread group but it does not run. 回答1: You need to use property, call JMeter batch with different property value, with 10 threads for example jmeter -JthreadNum=10 -t myJmx.jmx And in your Test Plan get the property in your Number of Threads: ${__P

Python Tkinter Threading - How to end / kill / stop thread when user closes GUI

﹥>﹥吖頭↗ 提交于 2020-01-22 02:08:08
问题 If I have a non for loop threaded task being run alongside tkinter such as time.sleep(seconds) how can I safely end the task before it has concluded, or, before the time.sleep() has ended. If you run the program and click the button and then close the GUI window then finished will still print in the interpreter window a few seconds later. Please note that in this case time.sleep() is just a placeholder for a long running non for loop function. # python 3 imports import tkinter as tk import

Python: Splitting up a sum with threads

两盒软妹~` 提交于 2020-01-22 01:59:10
问题 i have a costly calculation to do for fitting some experimental data. The fitting function is a sum over eigenmodes, each of them containing a specific surface integral. As it is rather slow if you do it the classical way i thought about threading it. I'm using python btw. The function i want to calculate is something like def fit_func(params , Mmin, Mmax): values = np.zeros(1000) for m in range(Mmin, Mmax): # Fancy Calculation for each mode # some calulation with all modes, adding them up

Write file need to optimised for heavy traffic part 3

…衆ロ難τιáo~ 提交于 2020-01-22 00:46:10
问题 this question is a continuation of the first 2 part, anyone who is interested to see where I come from you can refer to part 1 and part 2, but it is not necessary. write file need to optimised for heavy traffic Write file need to optimised for heavy traffic part 2 now i have a working snippet, the relevant part is below: public static class memoryStreamClass { static MemoryStream ms1 = new MemoryStream(); public static void fillBuffer(string outputString) { byte[] outputByte = Encoding.ASCII

I am trying to move a ball in applet using thread but its not moving

半世苍凉 提交于 2020-01-21 18:39:58
问题 I am trying to move a ball in applet using thread but its not moving. Can anyone help me out as m new to applet and proceeding for game development..for reference here is my code public class ballGame extends JApplet implements Runnable { int x_pos=50; int y_pos=100; int rad=10; Thread t; public void start() { super.start(); t=new Thread("t"); t.start(); } public void paint(Graphics g) { super.paint(g); g.setColor(Color.red); setBackground(Color.BLACK); g.drawOval(x_pos,y_pos,2*rad,2*rad);

I am trying to move a ball in applet using thread but its not moving

霸气de小男生 提交于 2020-01-21 18:39:04
问题 I am trying to move a ball in applet using thread but its not moving. Can anyone help me out as m new to applet and proceeding for game development..for reference here is my code public class ballGame extends JApplet implements Runnable { int x_pos=50; int y_pos=100; int rad=10; Thread t; public void start() { super.start(); t=new Thread("t"); t.start(); } public void paint(Graphics g) { super.paint(g); g.setColor(Color.red); setBackground(Color.BLACK); g.drawOval(x_pos,y_pos,2*rad,2*rad);

Schedule at 24hrs interval

假装没事ソ 提交于 2020-01-21 12:07:51
问题 I want to know the best method to schedule a code. I have a code that generates reports and sends mail to a set of people at interval of 24hrs. Its a console based java application. I want to know the best method to schedule that. Sometimes I may need to change that to 12hrs interval. However the application doesn't perform any other task in between the interval. 回答1: Here are few approach, from simplest to most comprehensive: sleep() : TimeUnit.HOURS.sleep(24) This approach is very simple,