Hi, so this is my program. All is working fine expcet stoping reading from console. Problem is that even after you write done if you are fast enought you are able to write more. As you can see I...
Type: Posts; User: Slapy
Hi, so this is my program. All is working fine expcet stoping reading from console. Problem is that even after you write done if you are fast enought you are able to write more. As you can see I...
I think it should execute 3 threads:
for (int i = 0; i < 3; i++)
pool.execute(new Counter(i));
or am I wrong?
--- Update ---
oh am so sorry. I messed it up. It should be just 3 threads not 4 and it is just luck which thread will be selected. For example this is one of my outputs.
It is just simpl program that have to count form 0 to 50 and to do so have to use 3 threads and output have to be:
Thread 1: 0
Thread 0: 1
Thread 2: 2
Thread 2: 3
Thread 1: 4
...
Thread 0: 50
Yes, I was just asking if there is any way how to do it better.
So here is it after few changes I made:
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
public class...
This are my two classes:
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Main {
public static int number = 0;
I find out that this
ClientDataSource ds = new ClientDataSource();
ds.setDatabaseName("testDB;create=true");
con = ds.getConnection();
is working.
First I was using this way how to get connection and all was fine.
con = DriverManager.getConnection("jdbc:derby:memory:datab;create=true");
But now I have to change it to DataSource and how...
System.out.println(rs); is getting back null but by my opinion it should get back that id or am I wrong?
god am so dumb. Problem was in line PreparedStatement query =...
Connection connection = null;
try {
connection = DriverManager.getConnection("jdbc:derby://localhost:1527/database","root","root");
connection.setAutoCommit(false);...
Hi can u help me? I have this string:
{"hash":"ckF3DaT","title":"","description":"","width":3264,"height":2448,"size":372322,"ext":".jpg","animated":0,"datetime":"2013-01-21...
I think everything is ok but program will end with output null. In real code I have my own API_ID this is just replacement.
Imgur JSON java reader - Pastebin.com
--- Update ---
What the ...?...
So that if have to break for if there are same values as you can see in first one it's all ok but in another ones it just failed I don't know why.
[-100.0, -100.0]; [-100.0, -100.0]
0; 5
true
...
Try to add this
System.out.println(vertices[0] +"; "+ pol.getVertex(i)); before
if (vertices[0].equals(pol.getVertex(i) ) ) break; and you will see it have to break that shitty for but it doesn't...
Sorry for duplicate I don't know how to delete it.
yes I am sure and like I said values of 4 digits: 0 5 5 5 have to be numbers of variable in array with match but it doesn't.
--- Update ---
It's just little bit different. First number have to...
it's value of int i but like I said output have to be 0 3 1 1 or 1 4 2 2 not 0 5 5 5 and there is no case when match is not found so I think it's not necessary to fix.
Edit: so value of i have to...
basically I am comparing two instances of class Vertex 2D.
int i = 0;
for (; i < vertices.length; i++) {
if (vertices[0].equals(pol.getVertex(i) ) ) break;
}
public abstract class SimplePolygon {
public abstract Vertex2D getVertex(int index) throws IllegalArgumentException;
public abstract int getNumVertices();
public double getArea() {
...