multi threads



Share on Google+Share on Google+

multi threads
1 Answer(s)      8 years ago
Posted in : Java Beginners
View Answers

April 16, 2009 at 10:38 AM

Hi friend,

Code to help in solving the problem :

public class SynchronizedMethod extends Object {
private static int count = 1;
public static synchronized int getCount() {
int i = count;
return i;
private static void print(String msg) {
String threadName = Thread.currentThread().getName();
System.out.println(threadName + ": " + msg);
public static void main(String[] args) {
try {
Runnable runnable = new Runnable() {
public void run() {
System.out.println("count=" + getCount());
Thread threadA = new Thread(runnable, "ThreadA");
Thread threadB = new Thread(runnable, "ThreadB");
Thread threadC = new Thread(runnable, "ThreadC");
Thread threadD = new Thread(runnable, "ThreadD");
} catch(Exception x ) {}



Related Tutorials/Questions & Answers:
multi threads - Java Beginners
multi threads  Hi i writing a multi threaded program in java .I m using three threads. I want to declare variables which will be available to all the threads to access. Is there a way to declare the variables as global variables
regardoing multi threads - Java Beginners
regardoing multi threads  Hi Please tell me how to declare global variables in main thread so that all other threads can use them and value will be available to all threads. Thanks
implementing an algorithm using multi threads - Java Beginners
implementing an algorithm using multi threads  Hi i need to implement an algorith in multi threads.Algorithm has data dependency so i need to pass... to breakdown into two or three threads and need to implemented and need
threads  what are threads? what is the use in progarmming
Multi Threading
Multi Threading  Hi... I need to solve the following question: Input an array of 10 integers. Separate the odd numbers, even numbers, positive numbers and negative numbers by different threads. I tried to solve it but I dont
multi threaded program - Java Beginners
multi threaded program  Hi i m developing a multi thread program to execute a real time algorith. I m using three threads. I want to share date between three threads .Is there a way to share data from one thread to another thread
threads in java
threads in java  how to read a file in java , split it and write into two different files using threads such that thread is running twice
threads and events
threads and events  Can you explain threads and events in java for me. Thank you.   Java Event Handling Java Thread Examples
Java threads
Java threads  What are the two basic ways in which classes that can be run as threads may be defined
multi language
multi language  Hello friends please help me Hi how can i do a java program using swing that changes the language like malayalam/tamil etc with languages on a drop down menu I am using netbeans IDE
multi thread
multi thread   Multiple Clients Connect to a server and communicate among the themselves. When a new Client is connected to the server, all other clients get the notification and they can chat with each other. Similarly when
disadvantage of threads
is the disadvantage of threads?   hello, The Main disadvantage of in threads... disadvantage of Threads. Let?s discuss the disadvantages of threads. The global..., the other threads using the same memory location will be killed automatically
multi dimension
multi dimension  class TwoDAgain{ public static void main(String args[]){ int twoD[][]=new int[4][]; twoD[0]= new int[1]; twoD[1]= new int[2]; twoD[2]= new int[3]; twoD[3]= new int[4]; int i, j, k = 0; for (i=0; i<4; i
Multi window
Multi window  I am making a bank app using struts 1.2. using only the struts tags and nno jsp tags and scriplets. db connected thru dao. 1st page contains all the details. when i submit this page, a new window opens and asks
Sync Threads
Sync Threads  "If two threads wants to execute a synchronized method in a class, and both threads are using the same instance of the class to invoke the method then only one thread can execute the method at a time." This is what
Java multi-threading
Java multi-threading  What is multi-threading
Multi-Threading - Java Beginners
Multi-Threading  Consider a producer process prime-generator produces prime numbers randomly that are displayed by a consumer process called prime... threads for the producer/consumer processes and call them randomly
threads in java
threads in java  iam getting that the local variable is never read in eclipse in main classas:: class Synex4{ public static void main(String args[]){ Test1 ob1=new Test1(); //local variable never read
multi threading code - Java Interview Questions
multi threading code  Hi this is Anji.My question is how to share the variable between two threads?.Can any one post the answer please
Version of cornerstone-threads>cornerstone-threads-api dependency
List of Version of cornerstone-threads>cornerstone-threads-api dependency
Version of cornerstone-threads>cornerstone-threads-impl dependency
List of Version of cornerstone-threads>cornerstone-threads-impl dependency
Version of cornerstone-threads>cornerstone-threads-tutorial dependency
List of Version of cornerstone-threads>cornerstone-threads-tutorial dependency
what is multi-threading .?
what is multi-threading .?   what is multi-threading.what is the use in real time, with example programs
Threads in realtime projects
Threads in realtime projects  Explain where we use threads in realtime projects with example
Coding for life cycle in threads
Coding for life cycle in threads  program for life cycle in threads