Search Results

Search found 655 results on 27 pages for 'synchronized'.

Page 3/27 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Does JavaME and/or Proguard reorder assignments?

    - by chrisdew
    This is a simplified example - I have two threads: Can JavaME and/Proguard ever reorder the obX = ... statements, such that thread_B will have a null pointer exception at ob2.someMethod? thread_A: Object ob1 = null; Object ob2 = null; ... ob1 = something1; ob2 = something2; thread_B: if (ob2 != null) { ob1.someMethod(); ... } P.S. I do realise that synchronising these will avoid the issue. Synchronisation has both a performance overhead, and more importantly, a chance to introduce deadlock.

    Read the article

  • Is it time to deprecate synchronized, wait and notify?

    - by OldCurmudgeon
    Is there a single scenario (other than compatibility with ancient JVMs) where using synchronized is preferable to using a Lock? Can anyone justify using wait or notify over the newer systems? Is there any algorithm that must use one of them in its implementation? I see a previous questions that touched on this matter but I would like to take this a little further and actually deprecate them. There are far too many traps and pitfalls and caveats with them that have been ironed out with the new facilities. I just feel it may soon be time to mark them obsolete.

    Read the article

  • Is there any way to keep launchers synchronized among machines?

    - by MMA
    Most of us use more than one machine for our purpose. The scenario for me is to use one at home, another at office. When comes to the launcher at left, the applications get added in chronological order. You can click and drag an application in launcher, but this is a tedious process. If your application placements are different among the machines, you loose the intuitive mouse click. You need to spend a few seconds to find out where actually the launcher is before you click on it. Is there any way I can keep the launcher applications (at least the locked ones) synchronized among machines? Thanks.

    Read the article

  • How to play multiple videos side-by-side synchronized?

    - by NoCanDo
    I've got 3 videos, all 3 have the same time, same amount of frames, and they only differ in terms of encoding quality. Now I need them to run side-by-side in synchronized fashion for evaluation purposes. Meaning when I press "play" BOTH! videos should start. Analogically for stop, forward, backward. Anyone know any player capable of doing that? Platform: Win7

    Read the article

  • How do I make my purchased music be synchronized on Rhythmbox and in ~./ubuntuone/Purchased from Ubuntu One?

    - by dln9
    I am signed up for the Ubuntu One service, and have my computer added. Under System ? Preferences ? Ubuntu One, I have enabled all synchronizations, including for music. System ? Prefereneces ? Ubuntu One, it shows this message: "Synchronization Complete". But, when (via Rhythmbox) I purchase a song, no synchronization occurs. I can see the purchased song on the Ubuntu One web page, but the "Purchased Music" folder in Rhythmbox is empty, and the folder ~/.ubuntuone/Purchased from Ubuntu One is also empty. (So, the only way I can get at the song is to manually download it from the Ubuntu One web site to my computer.) I thought that these synchronizations should just happen automatically, but it appears that is not the case for me, and I can't figure out why. Thanks in advance for any help.

    Read the article

  • How to keep a data structure synchronized over a network?

    - by David Gouveia
    Context In the game I'm working on (a sort of a point and click graphic adventure), pretty much everything that happens in the game world is controlled by an action manager that is structured a bit like: So for instance if the result of examining an object should make the character say hello, walk a bit and then sit down, I simply spawn the following code: var actionGroup = actionManager.CreateGroup(); actionGroup.Add(new TalkAction("Guybrush", "Hello there!"); actionGroup.Add(new WalkAction("Guybrush", new Vector2(300, 300)); actionGroup.Add(new SetAnimationAction("Guybrush", "Sit")); This creates a new action group (an entire line in the image above) and adds it to the manager. All of the groups are executed in parallel, but actions within each group are chained together so that the second one only starts after the first one finishes. When the last action in a group finishes, the group is destroyed. Problem Now I need to replicate this information across a network, so that in a multiplayer session, all players see the same thing. Serializing the individual actions is not the problem. But I'm an absolute beginner when it comes to networking and I have a few questions. I think for the sake of simplicity in this discussion we can abstract the action manager component to being simply: var actionManager = new List<List<string>>(); How should I proceed to keep the contents of the above data structure syncronized between all players? Besides the core question, I'm also having a few other concerns related to it (i.e. all possible implications of the same problem above): If I use a server/client architecture (with one of the players acting as both a server and a client), and one of the clients has spawned a group of actions, should he add them directly to the manager, or only send a request to the server, which in turn will order every client to add that group? What about packet losses and the like? The game is deterministic, but I'm thinking that any discrepancy in the sequence of actions executed in a client could lead to inconsistent states of the world. How do I safeguard against that sort of problem? What if I add too many actions at once, won't that cause problems for the connection? Any way to alleviate that?

    Read the article

  • linux "date -s" command not working to change date on a server

    - by nelaar
    date +%T --set="12:19:06" 12:19:06 date Mon Nov 26 12:37:32 SAST 2012 I have tried many different forms of this command but nothing seams to work. In changing the date on this computer server running as VM is not working. Our messages log show messages like thise ntpd[3496]: time correction of -1098 seconds exceeds sanity limit (1000); set clock manually to the correct UTC time. Our server is now about 20 minutes out. It seams like our server has not been updating the time correctly for a few days. Nov 22 19:29:23 hostname ntpd[1818]: time reset -998.577519 s Nov 22 19:32:34 hostname ntpd[1818]: synchronized to LOCAL(0), stratum 10 Nov 22 19:33:39 hostname ntpd[1818]: synchronized to 41.134.20.28, stratum 1 Nov 22 19:52:30 hostname ntpd[1818]: time reset -998.992426 s Nov 22 19:55:47 hostname ntpd[1818]: synchronized to LOCAL(0), stratum 10 Nov 22 19:56:53 hostname ntpd[1818]: synchronized to 41.134.20.28, stratum 1 Nov 22 20:13:04 hostname ntpd[1818]: time reset -999.374412 s Nov 22 20:16:40 hostname ntpd[1818]: synchronized to LOCAL(0), stratum 10 Nov 22 20:17:44 hostname ntpd[1818]: synchronized to 41.134.20.28, stratum 1 Nov 22 20:32:02 hostname ntpd[1818]: time reset -999.716832 s Nov 22 20:35:28 hostname ntpd[1818]: synchronized to LOCAL(0), stratum 10 Nov 22 20:36:16 hostname ntpd[1818]: synchronized to 41.134.20.28, stratum 1 Nov 22 20:56:39 hostname ntpd[1818]: time correction of -1000 seconds exceeds sanity limit (1000); set clock manually to the correct UTC time.

    Read the article

  • How to play multiple videos side-by-side synchronized?

    - by Don Salva
    I've got 3 videos, all 3 have the same time, same amount of frames, and they only differ in terms of encoding quality. Now I need them to run side-by-side in synchronized fashion for evaluation purposes. Meaning when I press "play" BOTH! videos should start. Analogically for stop, forward, backward. Anyone know any player capable of doing that? By that I mean playing more than 1 video side-by-side... Platform: Win7

    Read the article

  • How to synchronize static method in java.

    - by Summer_More_More_Tea
    Hi there: I come up with this question when implementing singleton pattern in Java. Even though the example listed blow is not my real code, yet very similar to the original one. public class ConnectionFactory{ private static ConnectionFactory instance; public static synchronized ConnectionFactory getInstance(){ if( instance == null ){ instance = new ConnectionFactory(); } return instance; } private ConnectionFactory(){ // private constructor implementation } } Because I'm not quite sure about the behavior of a static synchronized method, I get some suggestion from google -- do not have (or as less as possible) multiple static synchronized methods in the same class. I guess when implementing static synchronized method, a lock belongs to Class object is used so that multiple static synchronized methods may degrade performance of the system. Am I right? or JVM use other mechanism to implement static synchronized method? What's the best practice if I have to implement multiple static synchronized methods in a class? Thank you all! Kind regards!

    Read the article

  • Is there a way to keep two videos synchronized in a webpage without plugins?

    - by Jared
    Is there a way to use two HTML5 video tags on a page and keep the videos synchronized? Meaning that if the first video is at 15.2 seconds then the second video is at 15.2 seconds? I've looked around and found SMIL but it looks like that only works in IE. I also tried to implement something of my own with jQuery and jMediaElement but there appears to be a lot of cases where the videos can get out of sync. Has this been done before?

    Read the article

  • Speed of Synchronization vs Normal

    - by Swaranga Sarma
    I have a class which is written for a single thread with no methods being synchronized. class MyClass implements MyInterface{ //interface implementation methods, not synchronized } But we also needed a synchronized version of the class. So we made a wrapper class that implements the same interface but has a constructor that takes an instance of MyClass. Any call to the methods of the synchronized class are delegated to the instance of MyClass. Here is my synchronized class.. class SynchronizedMyClass implements MyInterface{ //the constructor public SynchronizedMyClass(MyInterface i/*this is actually an instance of MyClass*/) //interface implementation methods; all synchronized; all delegated to the MyInterface instance } After all this I ran numerous amounts of test runs with both the classes. The tests involve reading log files and counting URLs in each line. The problem is that the synchronized version of the class is consistently taking less time for the parsing. I am using only one thread for the teste, so there is no chance of deadlocks, race around condition etc etc. Each log file contains more than 5 million lines which means calling the methods more than 5 million times. Can anyone explain why synchronized versiuon of the class migt be taking less time than the normal one?

    Read the article

  • How to keep Lucene index synchronized with Mysql database?

    - by ?????
    I am trying to utilize Lucene to develop full text search in my application, which need to build index based on my mysql database. I was wondering is how to keep these index synchronized with db? I came up with to ways: 1) add extra code in business logic tightly to update the search index . 2) running a separated task to rebuild the index periodically. do you have any other approaches? and what do you think is the best way? Any comments would be appreciate, thanks in advance!

    Read the article

  • What is the best way to keep a folder synchronized with my USB drive?

    - by Ivo Flipse
    I know there is a similar topic on syncing between computers, but I'm looking for an application to run on one computer that will sync a "document/file" folder with a folder on my secondary/external USB drive. What would be the best solution? I know I could use Dropbox & Live Mesh, but they use up bandwith which isn't very good when I drop in a lot of large files. I'm running Windows 7, but I assume any solution for Windows Vista would work just fine.

    Read the article

  • Optimizing a thread safe Java NIO / Serialization / FIFO Queue [migrated]

    - by trialcodr
    I've written a thread safe, persistent FIFO for Serializable items. The reason for reinventing the wheel is that we simply can't afford any third party dependencies in this project and want to keep this really simple. The problem is it isn't fast enough. Most of it is undoubtedly due to reading and writing directly to disk but I think we should be able to squeeze a bit more out of it anyway. Any ideas on how to improve the performance of the 'take'- and 'add'-methods? /** * <code>DiskQueue</code> Persistent, thread safe FIFO queue for * <code>Serializable</code> items. */ public class DiskQueue<ItemT extends Serializable> { public static final int EMPTY_OFFS = -1; public static final int LONG_SIZE = 8; public static final int HEADER_SIZE = LONG_SIZE * 2; private InputStream inputStream; private OutputStream outputStream; private RandomAccessFile file; private FileChannel channel; private long offs = EMPTY_OFFS; private long size = 0; public DiskQueue(String filename) { try { boolean fileExists = new File(filename).exists(); file = new RandomAccessFile(filename, "rwd"); if (fileExists) { size = file.readLong(); offs = file.readLong(); } else { file.writeLong(size); file.writeLong(offs); } } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } channel = file.getChannel(); inputStream = Channels.newInputStream(channel); outputStream = Channels.newOutputStream(channel); } /** * Add item to end of queue. */ public void add(ItemT item) { try { synchronized (this) { channel.position(channel.size()); ObjectOutputStream s = new ObjectOutputStream(outputStream); s.writeObject(item); s.flush(); size++; file.seek(0); file.writeLong(size); if (offs == EMPTY_OFFS) { offs = HEADER_SIZE; file.writeLong(offs); } notify(); } } catch (IOException e) { throw new RuntimeException(e); } } /** * Clears overhead by moving the remaining items up and shortening the file. */ public synchronized void defrag() { if (offs > HEADER_SIZE && size > 0) { try { long totalBytes = channel.size() - offs; ByteBuffer buffer = ByteBuffer.allocateDirect((int) totalBytes); channel.position(offs); for (int bytes = 0; bytes < totalBytes;) { int res = channel.read(buffer); if (res == -1) { throw new IOException("Failed to read data into buffer"); } bytes += res; } channel.position(HEADER_SIZE); buffer.flip(); for (int bytes = 0; bytes < totalBytes;) { int res = channel.write(buffer); if (res == -1) { throw new IOException("Failed to write buffer to file"); } bytes += res; } offs = HEADER_SIZE; file.seek(LONG_SIZE); file.writeLong(offs); file.setLength(HEADER_SIZE + totalBytes); } catch (IOException e) { throw new RuntimeException(e); } } } /** * Returns the queue overhead in bytes. */ public synchronized long overhead() { return (offs == EMPTY_OFFS) ? 0 : offs - HEADER_SIZE; } /** * Returns the first item in the queue, blocks if queue is empty. */ public ItemT peek() throws InterruptedException { block(); synchronized (this) { if (offs != EMPTY_OFFS) { return readItem(); } } return peek(); } /** * Returns the number of remaining items in queue. */ public synchronized long size() { return size; } /** * Removes and returns the first item in the queue, blocks if queue is empty. */ public ItemT take() throws InterruptedException { block(); try { synchronized (this) { if (offs != EMPTY_OFFS) { ItemT result = readItem(); size--; offs = channel.position(); file.seek(0); if (offs == channel.size()) { truncate(); } file.writeLong(size); file.writeLong(offs); return result; } } return take(); } catch (IOException e) { throw new RuntimeException(e); } } /** * Throw away all items and reset the file. */ public synchronized void truncate() { try { offs = EMPTY_OFFS; file.setLength(HEADER_SIZE); size = 0; } catch (IOException e) { throw new RuntimeException(e); } } /** * Block until an item is available. */ protected void block() throws InterruptedException { while (offs == EMPTY_OFFS) { try { synchronized (this) { wait(); file.seek(LONG_SIZE); offs = file.readLong(); } } catch (IOException e) { throw new RuntimeException(e); } } } /** * Read and return item. */ @SuppressWarnings("unchecked") protected ItemT readItem() { try { channel.position(offs); return (ItemT) new ObjectInputStream(inputStream).readObject(); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } }

    Read the article

  • What are the ways to do synchronized streaming video and text?

    - by Marc
    I would like to have two streams. One being traditional streaming video and another being text. I will also build an interface that allows the user to create the text portion while watching the video. The context of these videos are usually that of an individual being filmed doing a presentation and later the next day for example, a coach will make text annotations (structured data is a plus) with the result being the text stream. It seems this is possible with Silverlight (see the article in the latest MSDN). However, what other methods are there if any? If there any, please give the reasons for why you are recommending them. Thanks. Also, I would prefer something that inst a software as a service hosted solution, but, dont let that keep you from giving an answer. Also keep in mind, the user shouldn't have to do any re-encoding of the video source, the text stream should be separate with someway to synchronize a coach's comments to an arbitrary time stamp in the video.

    Read the article

  • How the reading from and writing to sockets are synchronized?

    - by Roman
    We create a socket. On one side of the socket we have a "server" and on another side there is a "client". Both, the server and client, can write to and read from the socket. It is what i understand. I do not understand the following things: If a server reads from the socket, does it see in the socket only those stuff which was written to the socket by the client? I mean if server writes something to the socket and than reads from the socket, will it (server) see in the socket the stuff it (server) wrote there? I hope not. Let's consider the following situation. A client write something to the socket and then it writes something new to the socket and then server reads from the socket. What will the server see there? Only the "new" stuff written by the client or both "new" and "old" one? If a client (or server) writes to the socket, can it see if the written information was received by other side? For example out.println("Hello, Server!") will return true it server received this message.

    Read the article

  • How can I force a subscriber to be synchronized from a local snapshot?

    - by Brian
    Hello, I have a SQL 2005 server replicating(merge\push) to SQL 2005 and SQL 2000 servers. I have multiple subscribers spread througout the United states. I have set , @snapshot_in_defaultfolder = N'false', @alt_snapshot_folder = N'c:\snapshots\Merge\' (sample location). I take the snapshot from the publisher that is in the same location, 'c:\snapshots\Merge\', and copy it to the subscribers. I wanted to avoid applying the snapshot over the WAN but from the performance I am getting the synchronization is going over the WAN. Does anybody have any ideas how to make sure that I am using the local copy of the snapshot and not the copy at the publisher? Thanks

    Read the article

  • Multithreading in lwjgl getting rid of sleep.

    - by pangaea
    I'm trying to use multithreading in my game. However, I can't seem to get rid of the sleep. If I don't it's a blank screen, as there is no time for the computer to actually render the triangleMob as it can't access getArrayList(), in my main class I have a TriangleMob arraylist. If I delay it, then it can access the previousMob and it renders. If I don't, then it's blank screen. Can I get rid of the delay? Also, is this a bad way to multithread? Surely, this should be fast. I need multithreading so can you please not suggest not using it. public class TriangleMob extends Thread implements Runnable { private static int count=0; private int objectDisplayList; private static ArrayList<TriangleMob> previousMob = new ArrayList<TriangleMob>(); private static ArrayList<TriangleMob> currentMob = new ArrayList<TriangleMob>(); private static ArrayList<TriangleMob> laterMob = new ArrayList<TriangleMob>(); private Vector3f position = new Vector3f(0f,0f,0f); private Vector3f movement = new Vector3f(0f,0f,0f); public TriangleMob() { // Create the display list CreateDisplayList(); count++; } public TriangleMob(Vector3f position) { // Create the display list CreateDisplayList(); this.position = position; count++; } private void CreateDisplayList() { objectDisplayList = glGenLists(1); glNewList(objectDisplayList, GL_COMPILE); { double topPoint = 0.75; glBegin(GL_TRIANGLES); glColor4f(1, 1, 0, 1f); glVertex3d(0, topPoint, -5); glColor4f(0, 0, 1, 1f); glVertex3d(-1, -0.75, -4); glColor4f(0, 0, 1, 1f); glVertex3d(1, -.75, -4); glColor4f(1, 1, 0, 1f); glVertex3d(0, topPoint, -5); glColor4f(0, 0, 1, 1f); glVertex3d(1, -0.75, -4); glColor4f(0, 0, 1, 1f); glVertex3d(1, -0.75, -6); glColor4f(1, 1, 0, 1f); glVertex3d(0, topPoint, -5); glColor4f(0, 0, 1, 1f); glVertex3d(1, -0.75, -6); glColor4f(0, 0, 1, 1f); glVertex3d(-1, -.75, -6); glColor4f(1, 1, 0, 1f); glVertex3d(0, topPoint, -5); glColor4f(0, 0, 1, 1f); glVertex3d(-1, -0.75, -6); glColor4f(0, 0, 1, 1f); glVertex3d(-1, -.75, -4); glEnd(); glColor4f(1, 1, 1, 1); } glEndList(); } public static int getCount() { return count; } public Vector3f getMovement() { return movement; } public Vector3f getPosition() { return position; } public synchronized int getObjectList() { return objectDisplayList; } public synchronized static ArrayList<TriangleMob> getArrayList(){ if(previousMob != null) { return previousMob; } previousMob.add(new TriangleMob()); return previousMob; } public synchronized void move(Vector3f movement) { // If you want to move in all 3 axis position.x += movement.x; position.y += movement.y; position.z += movement.z; } public synchronized void render() { glPushMatrix(); glTranslatef(-position.x, -position.y, -position.z); glCallList(objectDisplayList); glPopMatrix(); } public synchronized static void setTriangleMob(ArrayList<TriangleMob> triangleMobSet) { laterMob = triangleMobSet; } private synchronized void setPreTriangleMob(ArrayList<TriangleMob> currentMob2) { previousMob = currentMob2; } public void run(){ while(true) { if(laterMob == null) { currentMob = laterMob; System.out.println("Copying"); } for(int i=0; i<currentMob.size(); i++) { currentMob.get(i).move(new Vector3f(0.1f,0.01f,0.01f)); } setPreTriangleMob(currentMob); try { sleep(1L); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }

    Read the article

  • Java Thread - Synchronization issue

    - by Yatendra Goel
    From Sun's tutorial: Synchronized methods enable a simple strategy for preventing thread interference and memory consistency errors: if an object is visible to more than one thread, all reads or writes to that object's variables are done through synchronized methods. (An important exception: final fields, which cannot be modified after the object is constructed, can be safely read through non-synchronized methods, once the object is constructed) This strategy is effective, but can present problems with liveness, as we'll see later in this lesson. Q1. Is the above statements mean that if an object of a class is going to be shared among multiple threads, then all instance methods of that class (except getters of final fields) should be made synchronized, since instance methods process instance variables?

    Read the article

  • Synchronizing access to an inner object's methods?

    - by user291701
    Suppose I have the following: public class Foo { private ReadingList mReadingList = new ReadingList(); public ReadingList getReadingList() { synchronized (mReadingList) { return mReadingList; } } } If I try modifying the ReadingList object in two threads, the synchronization above won't help me, right?: // Thread 1 foo1.getReadingList().setName("aaa"); // Thread 2 foo2.getReadingList().setName("bbb"); do I have to wrap each method I want synchronized like so: public class Foo { private ReadingList mReadingList = new ReadingList(); public synchronized void setReadingListName(String name) { mReadingList.setName(name); } public synchronized void setReadingListAuthor(String author) { mReadingList.setAuthor(author); } ... and so on for each method of ReadingList I want exposed and synched? I'd end up just writing wrapper methods for each method of ReadingList. Thanks

    Read the article

  • Java threading problem

    - by Krt_Malta
    Hi! I'm using multiple threads in my application. Basically I have a combo box and upon selecting Inbox, p1 resumes and p2 is suspended and upon selecting Send, p2 starts and p1 stops. Below is the code (I'm sure it's not perfect) public void modifyText(ModifyEvent e) { if (combo.getText().equals("Inbox")) { synchronized(p2) { p2.cont = false; } table.removeAll(); synchronized(p1) { p1.cont = true; p1.notify(); } } else if (combo.getText().equals("Sent")) { synchronized(p2) { p1.cont = false; } table.removeAll(); synchronized(p1) { p2.cont = true; p2.notify(); } } } }); and for P1 and P2 I have this inside their while loops: synchronized (this) { while (cont == false) try { wait(); } catch (Exception e) { } } ... As it is it's now working (I'm a beginner to threads). On pressing Sent in the combo box, I get an IllegalStateMonitorException. Could anyone help me solve the problem plz? Thanks and regards, Krt_Malta

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >